• ### Announcements

#### Archived

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

# Synchronizing Frame Rates / Game Speed

## Recommended Posts

yanuart    162
Hi, I''m having problem to synchronize my game speed during the game. The situation was caused by the fact that the rendering time each frame may differs depending if my scene happened to have complex mesh or not, imagine that you are in a building, of course the buliding it''s quite complex so my frame rate is lower (let''s say 40 fps) then for example if I move to the outside street (which is nothing but an empty street) I''ll get 60 fps. How can I determined the the threshold value of my fps, for ex. I wan''t to get 40 fps even in a scene which I can get higher fps so I can assure that my game speed is always the same at all time. What kinda ideas to implement this synchronization ?? do u use delay ?? How do you guys doing it ?? How can I predict my fps so that I can calculate the amount of delay ?? Thx !!!

##### Share on other sites
Why not just implement movement based on your FPS speed? You can calculate how long each frame takes to draw, and move objects the appropriate speed.

Example:
You have a ball, you wish to move the ball 10 units in 1 second. If you are running at 20 Frames Per second, you would move the ball by 0.5 units every frame... (10/20=0.5) 0.5 * 20 = 10. Now, lets say it was only running at 10 FPS. You need to move the ball by 1 unit ever frame (10/10=1) 1*10 = 10!

Billy - BillyB@mrsnj.com
(Hey, I''''m no longer anonymous!)

##### Share on other sites

I can see what you are saying but that adds a divide for each object that is to be moved per frame eg this could be 10s/100s of divides per game loop

Is there an equivilent calculation which does not use a divide?

Lost.......Assumed Coding!

##### Share on other sites
henrym    103
yanuart, I think you need framerate independent movement.
There are lots of topics on this at the forums and links articles on it too. Check here, and search.

Basically, the formula is something like:
movmentval = desiredDistanceToMovePerSecond * secondsPerFrame

BadBazza - this formula uses times not divide. Although, I am not sure whether it is faster or not.

Henry