| View previous topic :: View next topic |
| Author |
Message |
KawaGeo
Joined: 27 Aug 2005 Posts: 191 Location: Calif Mountains
|
Posted: Mon Sep 19, 2005 6:08 am Post subject: Player Motion Test |
|
|
I had experimented some codes for player motion. Here is the final version as of today ...
| Code: | -- movetest.lua by Geo Massar
function move()
local limit = 11 -- adjust the count limit as needed
local pad = Controls.read()
if (pad ~= oldpad) or (countpads > limit) then
if pad:right() then
playerPos = playerPos + 1
if playerPos > 13 then playerPos = 13 end
end
if pad:left() then
playerPos = playerPos - 1
if playerPos < 1 then playerPos = 1 end
end
if pad == oldpad then
countpads = limit - 2 -- for repeatedly advanced
else
countpads = 0 -- for the first pressed
end
oldpad = pad
else -- do nothing for a moment
countpads = countpads + 1
end
end
player = Image.load "player.png"
playerPos = 1
countpads = 0
while true do
screen:clear()
move()
screen:blit(32*playerPos, 120, player)
screen.waitVblankStart()
screen:flip()
end
|
I borrowed smiley icon from cynuber's Lsokoban. The test had met my satisfaction on both LP for Win and PSP. I set the count limit to 11 so that the duration of the first pressed key is about 200 ms, long enough to release the key without a repeat. And, the repeat rate while holding the key down is about 20 steps per second.
Try the code and let me know.
Thanks. _________________ Geo Massar
Retired Engineer |
|
| Back to top |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Mon Sep 19, 2005 11:26 pm Post subject: |
|
|
hmm hard to say... maybe you should mod it a bit... lower the steps, so you see if the movement is still smooth with this amount of 'lag'
lumo
nore: player beams from field to field here... .oO(star trek *lol*) _________________ "Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com |
|
| Back to top |
|
 |
KawaGeo
Joined: 27 Aug 2005 Posts: 191 Location: Calif Mountains
|
Posted: Tue Sep 20, 2005 2:21 am Post subject: |
|
|
I am aware of the player being jumpy when moving in the same direction. Shortening steps would make the motion appearing smoother. The entire program would have to be overhauled for the smoother motion. It is a big job, not "a little bit of work". :)
Anyway, thanks for the suggestion. _________________ Geo Massar
Retired Engineer |
|
| Back to top |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Tue Sep 20, 2005 2:31 am Post subject: |
|
|
what about an variable that automatically adusts itself according to the distance (movement speed of the character) (high sistance, as in ur case, low updates, small distance, fasterupdates.. (value*-1))
i know its always easier to say: "just change this to that"
or my favourite one, which my boss told me once...
"just add a little checkboxes here and there, so i can controll all those things"
.oO(you know how much work CAN be behind a checkbox...)
greets
Lumo _________________ "Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com |
|
| Back to top |
|
 |
chaos
Joined: 10 Apr 2005 Posts: 135
|
Posted: Tue Sep 20, 2005 3:39 am Post subject: |
|
|
"just add a little checkboxes here and there, so i can controll all those things"
ouch.. _________________ Chaosmachine Studios: High Quality Homebrew. |
|
| Back to top |
|
 |
KawaGeo
Joined: 27 Aug 2005 Posts: 191 Location: Calif Mountains
|
Posted: Wed Sep 21, 2005 5:41 am Post subject: |
|
|
Huh, huh? English, please. _________________ Geo Massar
Retired Engineer |
|
| Back to top |
|
 |
|