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 

Time based movement

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



Joined: 21 Mar 2006
Posts: 6

PostPosted: Mon Apr 24, 2006 12:08 am    Post subject: Time based movement Reply with quote

I'm not used to a time based method, does anyone have any example code or tips?

Basically instead of moving a character by +1 or +2 (which just flies around the screen using the while loop), I want to control everything using a timer.

I couldn't seem to find anything specific searching the forums.
Back to top
View user's profile Send private message
KawaGeo



Joined: 27 Aug 2005
Posts: 191
Location: Calif Mountains

PostPosted: Mon Apr 24, 2006 1:30 am    Post subject: Reply with quote

Take a look at my code in LED Timer which comes with Lua Player distribution. This should give you some ideas how to use a timer.

Have fun!
_________________
Geo Massar
Retired Engineer
Back to top
View user's profile Send private message Send e-mail
chriso



Joined: 21 Mar 2006
Posts: 6

PostPosted: Mon Apr 24, 2006 2:12 am    Post subject: Reply with quote

Which example? I've only got a clock face one.

I've had a stab at trying to work out the frames per second. How does this look?


Code:

col_white = Color.new(255,255,255)

timer = Timer.new()
timer:start()

counter = 0
fps = 0

while true do
   
   -- current time since timer started (milliseconds)
   now = timer:time()
   
   -- increase the frame counter
   counter = counter + 1
   
   -- if we are at 1 second
   if now > 1000 then
   
      -- frames per seconds = counter ?
      fps = counter
      
      -- reset
      timer:reset()
      counter = 0
      timer:start()
   end
   
   screen:clear()
   screen:print(10,10,"time:"..now, col_white)
   screen:print(10,20,"counter: "..counter, col_white)
   screen:print(10,30,"fps: "..fps, col_white)
   
   screen.waitVblankStart()
   screen:flip()
end
Back to top
View user's profile Send private message
imhotep



Joined: 13 Dec 2005
Posts: 41

PostPosted: Tue Apr 25, 2006 9:57 pm    Post subject: Reply with quote

see here

http://forums.ps2dev.org/viewtopic.php?p=39385#39385
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