A C++ implementation of a fixed timestep game loop running at 90Hz.
- Fixed timestep integration at 90Hz using semi-implicit Euler
- Accumulator pattern to decouple physics updates from variable frame rates
- State interpolation for smooth rendering between physics steps
- Spiral of death prevention by capping maximum frame time
The loop maintains a consistent physics simulation regardless of how fast or slow the system runs. An accumulator tracks elapsed time and triggers fixed-step physics updates, while interpolation smooths the rendered output between discrete simulation states.
Linux/macOS:
g++ -o game_loop src/main.cppWindows (MinGW/g++):
g++ -o game_loop.exe src/main.cppWindows (MSVC):
cl /EHsc /Fe:game_loop.exe src/main.cppLinux/macOS:
./game_loopWindows:
game_loop.exeThe simulation runs for 10 seconds, displaying position and velocity of a simple accelerating object.
Based on Glenn Fiedler's article: Fix Your Timestep!