Skip to content
Skills Library
Programming · Building & coding

game-loop-architecture

/game-loop-architecture

Structure game loops with fixed-timestep simulation, interpolated rendering, and spiral-of-death protection. Use when building a game loop or fixing physics that behaves differently across frame rates.

Repository
AI-SKILLS ↗
Licence
MIT
Last repository change
05.09.2026

Assessment and security

90/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 05.09.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Structure game loops with fixed-timestep simulation, interpolated rendering, and spiral-of-death protection. Use when building a game loop or fixing physics that behaves differently across frame rates.

Original author description

Structure game loops with fixed-timestep simulation, interpolated rendering, and spiral-of-death protection. Use when building a game loop or fixing physics that behaves differently across frame rates.

How it works

  1. Method
  2. Boundaries
Original SKILL.md headings · 59 lines, 395 words
SKILL.md preview
---
name: game-loop-architecture
description: Structure game loops with fixed-timestep simulation, interpolated rendering, and spiral-of-death protection. Use when building a game loop or fixing physics that behaves differently across frame rates.
---

# Game loop architecture

The core decision: simulation runs on a fixed timestep for
determinism and stability; rendering runs as fast as it can and
interpolates. Mixing them ties gameplay correctness to frame rate,
which is how physics breaks on faster machines.

## Method

1. **Fix the simulation timestep.** Update at a constant dt
   (60Hz or 50Hz commonly): physics integrators stay stable,
   gameplay is reproducible, and networking/replays become
   possible (see multiplayer-netcode's determinism needs).
   Variable-dt simulation makes tunneling, jitter, and
   speed-depends-on-hardware bugs a permanent background noise.
2. **Run the accumulator loop.** Each frame: add real elapsed
   time to an accumulator, run as many fixed updates as it
   covers, render once with the leftover fraction. The canonical
   shape: `while (acc >= dt) { update(dt); acc -= dt; }
   render(acc/dt)`.
3. **Interpolate rendering between states.** Render entities at
   `prev + (curr - prev) * alpha` using the leftover fraction:
   motion looks smooth at any refresh rate while simulation
   stays discrete. Store previous transform per entity; snap
   (no interpolation) on teleports or spawns to avoid ghosting
   sweeps across the screen.
4. **Clamp the accumulator against the spiral of death.** A slow
   frame queues more updates, which makes the next frame slower:
   cap the accumulated time (e.g. max 5 updates per frame) and
   drop the excess, accepting slow-motion under overload over a
   frozen process. Log when the cap hits; it is your overload
   telemetry (see game-performance budgets).
5. **Order the frame deterministically.** Input sampling,
   then fixed updates (gameplay, physics), then late/camera
   update, then render, then present: one documented order.
   Input handled inside the fixed step (or queued into it) keeps
   behavior framerate-independent (see game-input-handling for
   buffering across the boundary).
6. **Keep time sources honest.** One monotonic clock for the
   loop (never wall clock; see clock-skew's lesson locally);
   pause/timescale implemented by scaling the accumulator feed,
   not by skipping updates; and separate "game time" from "real
   time" in APIs so UI animations can run while gameplay is
   paused.

## Boundaries

- Turn-based and event-driven games can use simpler
  update-on-demand loops; the accumulator machinery earns its
  keep where continuous simulation exists.
- Engines (Unity/Unreal/Godot) already implement this: there
  your job is putting logic in the right callback
  (fixed vs frame update) and respecting their interpolation
  settings, not rebuilding the loop.
- Frame pacing against the display (vsync, variable refresh)
  is a presentation concern layered on top; the fixed-step core
  stays the same underneath.

Versions

The database has no other skills named game-loop-architecture.

Database snapshot: 13.11.2026 · package version 9ae1a1e2bb03 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100game-development
    Game engine choice, game loop, input, physics, game feel, saves and shipping. Use when building, tuning or debugging a 2D or 3D game in any engine.
  • 90Game Developer
    Use for game development - game loop and frame timing, fixed timestep and interpolation, entity component systems and data-oriented design, physics and broadphase collision, AI and behavior state machines, rendering and asset pipelines, input handling, animation, audio, object…
  • 90game-engine-patterns
    Use this skill when the user says 'game loop', 'fixed timestep', 'game programming patterns', 'object pooling', 'spatial partitioning', 'command pattern game', 'state machine game'. Canonical engine patterns: game loop and fixed timestep, component architecture, spatial…
  • 100game-architecture
    Game architecture patterns and best practices for browser games. Use when designing game systems, planning architecture, structuring a game project, or making architectural decisions about game code.
  • 100realtime-game-loop
    Runs real-time play: a fixed-step UI-thread loop, typed-array sims, (tick, command) replays, replayable physics. Use when adding live motion, bouncing balls, a physics shot or a replay test. Not for turn animations (skia-canvas-rendering).
  • 100review-game
    Review an existing game codebase for architecture, performance, and best practices. Use when the user says "review my game", "code review", "check my game architecture", "is my game well structured", or "audit my game code". Do NOT use for making changes — this is read-only…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.