#### Archived

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

# Timed Animation

## 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 on other sites
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.

• ### Forum Statistics

• Total Topics
628301
• Total Posts
2981906

• 9
• 11
• 11
• 10
• 10