Take for example the first game loop from this question. A similar code is used in Minecraft (at least in older versions). I understand the concept and how this loop works in principle. But there is something I'm wondering about for a long time now. There are 20 tps (ticks per second) in Minecraft for example. There can be more fps (frames per second) than tps because the game loop renders as many frames as possible in the time which is left between the ticks. It's also clear to me, that one can do "partial ticks" or interpolations for each frame between the ticks to make the game smoother. This is actually the reason why there should be more fps than tps. Without the interpolations each frame between the ticks would be exactly the same.

Now suppose I write a game with 20 tps (50 ms (milliseconds) period) and an expected tick time of 40 ms as an extreme example. The expected tick time is the time, which the tick() function takes on average. Then there are 10 ms left each tick for rendering on average. Suppose rendering is very fast and the game still reaches 60 fps. However, the game wouldn't be smooth in this case because there are always long time intervals of about 40 ms, where no frame is rendered.

Of course I know that this is an extreme example and one would try to avoid such high tick times if possible. However, I want to know if there is a commonly used solution for this problem? Unfortunately I can't find any resources about this topic or this specific question.

I've come up with these ideas to solve this problem: One could try to ...

  • ... render frames based on the current number of fps and buffer the frames for a while, to show them more frequently and smooth.
  • ... tick and render on different threads. However, this has the disadvantage that one has to care about thread safety. The render thread must get or copy the data to show in a valid state somehow. This seems very inefficient and complicated.

Is there (another) common way to do this in game development?

  • 1
    \$\begingroup\$ It's an unusual situation to be in where your game state updates take many times longer than your rendering. Is this a real situation you've encountered in your game? \$\endgroup\$
    – DMGregory
    Aug 19, 2020 at 1:54
  • \$\begingroup\$ @DMGregory no it's not real. I'm actually wondering if this is a usual situation and if so, what's a common solution for the problem. But the answer is probably, as you said, that it's an unusual situation. \$\endgroup\$
    – stonar96
    Aug 19, 2020 at 2:05


You must log in to answer this question.

Browse other questions tagged .