Archived

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

Eber Kain

Timed Animation

Recommended Posts

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