Player Motion Test

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Player Motion Test

Post by KawaGeo »

I had experimented some codes for player motion. Here is the final version as of today ...

Code: Select all

-- 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&#58;clear&#40;&#41;
  move&#40;&#41;
  screen&#58;blit&#40;32*playerPos, 120, player&#41;
  screen.waitVblankStart&#40;&#41;
  screen&#58;flip&#40;&#41;
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
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

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
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

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
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

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
chaos
Posts: 135
Joined: Sun Apr 10, 2005 5:05 pm

Post by chaos »

"just add a little checkboxes here and there, so i can controll all those things"

ouch..
Chaosmachine Studios: High Quality Homebrew.
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

Huh, huh? English, please.
Geo Massar
Retired Engineer
Post Reply