We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Time (Read 795 times)
Time
Sep 26th, 2009, 6:06pm
 
Hey!  I just started using Processing and I've been coding a few simple things.  One thing that I'm confused is how to keep track of time in a program?  

For example, say that I would like to have a moving object that speeds up the longer the app has been running, how would I got about doing that?

Re: Time
Reply #1 - Sep 26th, 2009, 7:40pm
 
you can use millis http://processing.org/reference/millis_.html
that gives you the milliseconds since your app started.

another thing would be frames,  depending on what you are aiming for
you get them with "frameCount"
difference it that even when your programm slows down, millis dont.
but as the frameRate drops your frameCount does, so your animation slows down too. that could be either usefull or not.
Re: Time
Reply #2 - Sep 26th, 2009, 9:26pm
 
as Cedric says, each user will have a different framerate...for the most accurate timing, update the essential (logic) parts at a function of millis(), and update the rendering frame when possible.  -- Ben
Page Index Toggle Pages: 1