Skip to content
Mermaid templates

Game Loop

Fixed-timestep simulation loop with variable-rate render.

Template previewMermaid
Rendering…

Make it your own.

flowchart LR
Start[Start frame] --> Input[Read input]
Input --> Acc[Accumulate Δt]
Acc --> Step{accumulator ≥ dt?}
Step -- yes --> Sim[Simulate fixed step]
Sim --> Acc2[accumulator -= dt]
Acc2 --> Step
Step -- no --> Lerp[Interpolate render state]
Lerp --> Render[Render]
Render --> Sleep[Sleep / vsync]
Sleep --> Start