0

I am trying to understand the different ways of how to implement game loops and their advantages and disadvantages.

While researching, I found this:

http://entropyinteractive.com/2011/02/game-engine-design-the-game-loop/

But here is on thing that I don't fully understand:

"There are several options at this point. The first would be making the updates aware of how much time the loop took. For example, if the loop takes half as long as expected, only move the objects half as far. A game loop that has this behavior is sometime referred to as a “delta loop” or using “delta time”. Unless you are very careful, this can cause problems, particularly when updates are very fast or slow. This also makes the behavior of the game much less repeatable."

What could possibly happen, when updates are very fast or slow? And what does "much less repeatable" actually mean?

Maybe someone is able to explain that to me. Thanks! :)

Vulpecula
  • 135
  • 1
  • 10

1 Answers1

1

The classic issue that you can run into if updates are very slow is sometimes called the spiral of death: if a longer timestep causes your game to do more work to simulate that time (e.g. running extra physics steps), then that larger amount of work can cause a longer frame time, which causes yet more work to be done, which makes the frame time even longer, and so on. Most games with a delta time-based game loop will have some method of handling this case, even it's just a cap on the delta time. The issues with running too quickly are perhaps less obvious, but include increased power/battery consumption.

The issue of repetition is because a delta time-based loop gives up the possibility of determinism. If your game just runs as fast as it can, then every run will have very slightly different timesteps because of machine load and other external factors, so even if you replayed the exact same user input the game would behave slightly differently. If you step your game logic regularly at say 60Hz (independently of how often the game is rendered) then if you are (very) careful you can have repeatable results from your game.

Mantus
  • 101
  • 2