Skip to content

Latest commit

 

History

History
49 lines (34 loc) · 1.17 KB

File metadata and controls

49 lines (34 loc) · 1.17 KB

90Hz Fixed Timestep Loop

A C++ implementation of a fixed timestep game loop running at 90Hz.

Features

  • 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

How It Works

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.

Building

Linux/macOS:

g++ -o game_loop src/main.cpp

Windows (MinGW/g++):

g++ -o game_loop.exe src/main.cpp

Windows (MSVC):

cl /EHsc /Fe:game_loop.exe src/main.cpp

Running

Linux/macOS:

./game_loop

Windows:

game_loop.exe

The simulation runs for 10 seconds, displaying position and velocity of a simple accelerating object.

Reference

Based on Glenn Fiedler's article: Fix Your Timestep!