Archived

This topic is now archived and is closed to further replies.

Game timer frequency?

This topic is 5378 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm talking about game logic timer. That is used for time-based movement quantities like velocity and animation. You need to have some kind of a logic timer if you want accurate velocities for moving objects. Some sample code what I'm talking about.

double logicTimerFrequency=37; // 37 milliseconds
double objVelocity=20; // 20 units/sec
double preTickVelocity=objVelocity/1000*logicTimerFrequency;

// loop
object.x+=objVelocity;
...

Or, do modern games use totally different approach that I haven't thought of ?

[edited by - MOVSW on March 25, 2003 12:12:12 AM]

Share this post


Link to post
Share on other sites
I think what most games do is loop through as quickly as possible, each loop making adjustments proportional to the amount of time elapsed since the last loop.

object.x += objVelocity * secondsElapsed;

Share this post


Link to post
Share on other sites