forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

different movement speeds

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
imhotep



Joined: 13 Dec 2005
Posts: 41

PostPosted: Wed Mar 08, 2006 8:45 am    Post subject: different movement speeds Reply with quote

-- now obsolete code, see above for new---

Last edited by imhotep on Wed Mar 08, 2006 9:52 pm; edited 1 time in total
Back to top
View user's profile Send private message
ShUr1k3n



Joined: 16 Oct 2005
Posts: 42

PostPosted: Wed Mar 08, 2006 9:02 am    Post subject: Reply with quote

When u do this:

Code:

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")  }


U should use:
Code:

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")  }


and...when u use:

Code:

screen:blit(38,20,welle["w" .. wave])


Change to:

Code:

screen:blit(38,20,welle[wave])


Do the same thing with ur "player_straight"...

Regards,

ShUr1k3n
Back to top
View user's profile Send private message Send e-mail
imhotep



Joined: 13 Dec 2005
Posts: 41

PostPosted: Wed Mar 08, 2006 9:57 am    Post subject: Reply with quote

thx,not really the answer but helpful anyways, i'm trying an approach with keyframes right now.

how can i check if a division by a certain number leaves a rest, say .034 or so or not? that would be the key...
Back to top
View user's profile Send private message
imhotep



Joined: 13 Dec 2005
Posts: 41

PostPosted: Wed Mar 08, 2006 9:38 pm    Post subject: Reply with quote

I (AS A TOTAL NOOB!) DID IT!

i made a function that works with a keyframe concept, check it out!

Code:

-- 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




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??
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group