The heart of every game.
WHAT IT DOES, EACH FRAME
Gathers input Updates simulation state Renders the result Presents the frame
WHAT FRAME RATE MEANS
How many times per second that completes.
WHAT FRAME TIME IS
How long one iteration takes.
WHY FRAME TIME IS THE BETTER MEASURE
It is linear, and it reveals variance that an averaged rate conceals.
WHAT DELTA TIME IS
The elapsed time since the last frame.
WHY EVERY UPDATE MUST USE IT
Otherwise movement speed depends on frame rate, and the game runs differently on different machines.
WHAT A FIXED TIMESTEP IS
Updating simulation at a constant interval, independent of rendering.
WHY IT MATTERS
Physics and deterministic simulation break with variable steps.
HOW IT IS IMPLEMENTED
Accumulate elapsed time, and run as many fixed updates as fit, rendering with interpolation between them.
WHAT VARIABLE TIMESTEP SUITS
Rendering, animation, and anything not requiring determinism.
WHAT A SPIRAL OF DEATH IS
Updates taking longer than the timestep, so the accumulator grows and the game falls further behind.
WHAT PREVENTS IT
A maximum number of updates per frame.
WHAT TO NEVER DO
Assume a constant frame rate.