Constant framerate

Started by
6 comments, last by Xces 21 years, 11 months ago
Hey there, i want to know if there are calculations which make my code runs @ the same framerate on each machine...
Advertisement
Use a function like GetTickCount() to get the current time (in 1/1000 of a second). Your code would look something like this:
do  LastFrame=GetTickCount  RenderWorld  while (GetTickCount-LastFrame)<(1000/TargetFPS) do nothinguntil Quit 
Yeah ok, that could work Any other suggestins?
I usually don''t care how fast it updates the screen.
I just let it draw as fast as it can and then update the world (physics, movement, etc) 20-30 times a second.
If it misses any of the 20-30 times, it has to do the skipped updates too (either for(;missed updates update(); or update(delta_time).

This way people that have a slower computer(<20fps) also get to play at almost the same speed.
bloody smileys.
Anybody else does this thesame?
I do, but you said you wanted the same framerate on all machines, you didn''t say you wanted the game speed (how fast the characters move)with a variable frame rate.

If you''re looking for that I would suggest you read here (Gamedev article: Framerate Independent Movement)
Cool thanx, this is what i meant !

This topic is closed to new replies.

Advertisement