Jump to content
  • Advertisement
Sign in to follow this  
Deprecated

How to handle update-rate?

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

Have been working a little on a tile-based game/simulator to test and display different AI behaviour on my laptop. When running the simulator on my regular computer an uncapped framerate will obviously make the simulation go much faster.

The most obvious solution to the problem with too fast framerate was time.sleep(0.5) which made it run at (about) 2 FPS.

The second, also obvious, solution was to get the time it took to iterate one step, then subtract that from 1000 / 60 which made it run at (almost exactly) 60 FPS.

But what happends the other way around? Assume that I have two computers and tell them both at exactly the same time to move from A to B (without either of them being connected to the other, ultimatly controlled by a server). The first computer runs at 2 FPS and the second runs at 2000 FPS. How can I calculate the relative speed per update if I want them both to arrive at B, at the same time?

Writing this, I'm assuming that I'd have to multiply the time it took for each update with a distance per second value. But as it's tile-based both the minimum and maximum movement is 1. It would of course be possible to increase dx, dy until they were greater than 1, but that doesn't seem good enough as it could still differ as much as 1 / FPS seconds between the results.


As my above thoughs might seem a little messy, how can I normalize update-rate between different hardwares?

Share this post


Link to post
Share on other sites
Advertisement
Thanks!

As it is tile-based and I'm only working with integers for positions and angles I figure each entity should have internal "countdowns" for the amount of updates needed before moving or communicating with other entities (assuming it takes more than 1 timestep)?

Share this post


Link to post
Share on other sites

Use a fixed timestep. Explained here: http://gafferongames...-your-timestep/

This will decouple rendering framerate from the logic update rate.


+1 for the mention of this article. I found it very helpful myself.

In my first game prototype, I had coupled the frame rate and update rate. It worked okay for a prototype, but it's not correct. So when I rebooted my project (threw away a lot of the prototype code), decoupling the render and update timers was the first thing I did, thanks to this article. As a side effect, it also forced me to correctly model my physics simulations (making every movement _time_ dependent, instead of _tick_ dependent).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!