Fixed vs. variable frame rates in games: what is best, and when?

Question :

Fixed vs. variable frame rates in games: what is best, and when?,

Answer :

After working for a while developing games, I’ve been exposed to both variable frame rates (where you work out how much time has passed since the last tick and update actor movement accordingly) and fixed frame rates (where you work out how much time has passed and choose either to tick a fixed amount of time or sleep until the next window comes).

Which method works best for specific situations? Please consider:

  • Catering to different system specifications;
  • Ease of development/maintenance;
  • Ease of porting;
  • Final performance.
Read More  Learning FORTRAN In the Modern Era

,

I lean towards a variable framerate model, but internally some systems are ticked on a fixed timestep. This is quite easy to do by using a time accumulator. Physics is one system which is best run on a fixed timestep, and ticked multiple times per frame if necessary to avoid a loss in stability and keep the simulation smooth.

A bit of code to demonstrate the use of an accumulator:

const float STEP = 60.f / 1000.f;  float accumulator = 0.f;    void Update(float delta)  {      accumulator += delta;        while(accumulator > STEP)      {          Simulate(STEP);          accumulator -= STEP;      }  }  

This is not perfect by any means but presents the basic idea – there are many ways to improve on this model. Obviously there are issues to be sorted out when the input framerate is obscenely slow. However, the big advantage is that no matter how fast or slow the delta is, the simulation is moving at a smooth rate in “player time” – which is where any problems will be perceived by the user.

Read More  How do you list all processes on the command line in Windows?

Generally I don’t get into the graphics & audio side of things, but I don’t think they are affected as much as Physics, input and network code.

That’s the answer Fixed vs. variable frame rates in games: what is best, and when?, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you

Read More  Beginning TDD – Challenges? Solutions? Recommendations?