← Back to miito.dev

Digital Garden

October 21
Garden HubAutomotiveTypeScriptTestingSVGSQLSecurityReactPerformanceNode.jsModdingJavaScriptGame DevDevOpsDesignCSSCommunication
miito.dev
© Brian Dinh (miito.dev)
✕
✕
§ GARDEN · GAME-DEV · CLASS OPEN
NODE FILE · ENTRY

The Game Loop Pattern

FILED UNDER · GAME-DEV
①Read
②Meta

Fixed timestep, variable rendering, and the deceptively tricky problem of making games run at the same speed everywhere.

Every game is a loop: read input, update state, render frame, repeat. But the naive approach — update and render once per iteration — ties game speed to frame rate. On a fast machine the game runs too fast; on a slow one it crawls. The fixed timestep pattern solves this elegantly.

Fixed Update, Variable Render

Accumulate real elapsed time. Run physics/logic updates in fixed-size steps (e.g. 1/60th of a second) until the accumulator is drained. Render as fast as possible, interpolating between the last two physics states for smooth visuals. Physics is deterministic and frame-rate-independent. Rendering is as smooth as the hardware allows.

DTNRWORKSHOP ARMAMENTSSN 2012.OTT.0176