different movement speeds
Moderators: Shine, Insert_witty_name
different movement speeds
-- now obsolete code, see above for new---
Last edited by imhotep on Wed Mar 08, 2006 9:52 pm, edited 1 time in total.
When u do this:
U should use:
and...when u use:
Change to:
Do the same thing with ur "player_straight"...
Regards,
ShUr1k3n
Code: Select all
welle = { w1=Image.load("wave0000.jpg"),
w2=Image.load("wave0001.jpg"),
w3=Image.load("wave0002.jpg"),
w4=Image.load("wave0003.jpg"),
w5=Image.load("wave0004.jpg"),
w6=Image.load("wave0005.jpg"),
w7=Image.load("wave0006.jpg"),
w8=Image.load("wave0007.jpg"),
w9=Image.load("wave0008.jpg"),
w10=Image.load("wave0009.jpg"),
w11=Image.load("wave0010.jpg") }
Code: Select all
welle = { [1]=Image.load("wave0000.jpg"),
[2]=Image.load("wave0001.jpg"),
[3]=Image.load("wave0002.jpg"),
[4]=Image.load("wave0003.jpg"),
[5]=Image.load("wave0004.jpg"),
[6]=Image.load("wave0005.jpg"),
[7]=Image.load("wave0006.jpg"),
[8]=Image.load("wave0007.jpg"),
[9]=Image.load("wave0008.jpg"),
[10]=Image.load("wave0009.jpg"),
[11]=Image.load("wave0010.jpg") }
Code: Select all
screen:blit(38,20,welle["w" .. wave])
Code: Select all
screen:blit(38,20,welle[wave])
Regards,
ShUr1k3n
I (AS A TOTAL NOOB!) DID IT!
i made a function that works with a keyframe concept, check it out!
so objectnumber is 1 for wave and 2 for straight (movement of the surfer)
frame is at which frame and x*frame the change in the animation step occurs
limit is the number of animation steps
hope someone likes it :)
any suggestions??
i made a function that works with a keyframe concept, check it out!
Code: Select all
-- objects
timeline=1000
frames=1
object = {wave,straight}
player_straight = { [1]=Image.load("s1.png"),
[2]=Image.load("s1.png"),
[3]=Image.load("s3.png") }
welle = { [1]=Image.load("wave0000.jpg"),
[2]=Image.load("wave0001.jpg"),
[3]=Image.load("wave0002.jpg"),
[4]=Image.load("wave0003.jpg"),
[5]=Image.load("wave0004.jpg"),
[6]=Image.load("wave0005.jpg"),
[7]=Image.load("wave0006.jpg"),
[8]=Image.load("wave0007.jpg"),
[9]=Image.load("wave0008.jpg"),
[10]=Image.load("wave0009.jpg"),
[11]=Image.load("wave0010.jpg") }
function frameskip(objectnumber,frame,limit)
--is frame nil or zero?
if frame==0 or frame==nil then
frame=1 end
--is object==nil?
if object[objectnumber]==nil then
object[objectnumber]=1 end
--frames for every timer : 1000-->reset follows
--how many times is timeline dividable by frame?
res=math.floor(timeline/frame)
for i=1,res do
if i*frame==frames then
-- increase object[..] by 1
-- test if limit of animation steps is reached
object[objectnumber]=object[objectnumber]+1
if object[objectnumber]>limit then
object[objectnumber]=1
end
end
end
--count++ & reset the timer if >timeline
frames=frames+1
if frames>=timeline then frames=1 end
number=object[objectnumber]
return number
end
function anim_surfer()
pad=Controls.read()
if pad:left() then
if xpos>=50 then xpos=xpos-10 end
screen:blit(xpos,ypos,player_left,true)
elseif pad:right() then
if xpos<380 then xpos=xpos+10 end
screen:blit(xpos,ypos,player_right,true)
elseif pad:up() then
frameskip(2,60,1)
else
-- straight movement, three animation steps
frameskip(2,20,3)
screen:blit(xpos,ypos,player_straight[number],true)
end
end
frame is at which frame and x*frame the change in the animation step occurs
limit is the number of animation steps
hope someone likes it :)
any suggestions??