D2 log 051 – Fixing my timestep

In Superforce, it was safe to assume that the game would run at a constant rate of  60 frames per second. This was thanks to

  • predictable hardware and software environment
  • fast, simple rendering and game update logic

The game logic could thus be directly locked to the framerate. This assumption is not valid for Devastro 2. I have no idea what machines it will run on. I don’t even know if VSYNC works on all of them.

There’s a great article called “Fix your timestep” which describes a good way to decouple game updates from rendering.

After making a few changes in my code, I have indeed fixed my timestep. Toggling VSYNC causes a big FPS increase and yet gameplay keeps running normally.

I was not able to fully implement the last step from the article, which is interpolation. It would require more substantial changes to the game and I just didn’t have time for that. I may or may not do that later as the… next step.

I might add interpolation for the camera position, which could smooth things out even more without too much work.