Jump to content
  • Advertisement

Archived

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

Eber Kain

Timed Animation

This topic is 6271 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 was wondering, how many miliseconds is common between updates in a timer loop program? I was trying 50, but things still seem a bit jerky.

Share this post


Link to post
Share on other sites
Advertisement
30fps -> 0.03333 ms
60fps -> 0.01666 ms

But if I get your drift, I think that you are trying to lock your frame rate. *DON''T*[\B] do that. It sounds like your doing something like:

  
while(!exit)
{
startTime = GetTime();
GameLogicRenderStuff();
endTime = GetTime();
Sleep(50 - (endTime - startTime));
}


That''s the biggest mistake that people make. And a big reason that people do that is because that''s what Andre LaMothe does in his newbie books.(He writes pretty good books. I just hate the fact he does that) Do something like this instead:

  
dt = 0.0f;

while(!exit)
{
startTime = GetTime();
UpdateWorld(dt);
RenderWorld();

endTime = GetTime();
dt = endTime - startTime;
}


Why wouldn''t you want to run as many frames per second as possible? But you can only do this if you update the world as a function of how much time has elapsed since the last frame.


Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!