Skip to content

GAllen98/Fixed-Timestep-Loop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

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!

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages