Archived

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

Constant framerate

This topic is 5705 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

Hey there, i want to know if there are calculations which make my code runs @ the same framerate on each machine...

Share this post


Link to post
Share on other sites
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 nothing
until Quit

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites