Game implementation patterns and code structure. Invoked by game-orchestra when a design exists but code doesn't. Covers scaffolding, game loops, state management, integration hooks, and iterative development workflow.
Guides implementation of web games — project setup, architecture, integration hooks, and iterative development.
By game-orchestra when a game design document exists but code doesn't.
Read the game design document (game-design.md) and extract key decisions
that affect implementation.
STEP 1 COMPLETE: Key decisions affecting implementation: [list mechanics, architecture choice, state approach, input type, content structure].
Set up the project structure.
npm create vite@latest)index.html with inline or linked scriptnpm run dev on http://localhost:5173Single file: all logic in one game.js or game.ts.
src/
├── game.ts # Entry point, game loop
├── state.ts # State machine
├── entities.ts # Game objects
├── renderer.ts # Drawing/rendering
├── input.ts # Input handling
└── types.ts # Type definitions
STEP 2 COMPLETE: Files created: [list all files created]. Structure: [single/modular]. Build tool: [tool].
Set up the core game loop and state management.
requestAnimationFrame (canvas) or DOM event-drivenSee references/game-patterns.md for patterns.
STEP 3 COMPLETE: Loop type: [rAF/DOM event-driven]. State management: [approach]. States: [list of game states].
Every game MUST implement these two hooks for testing.
See game-integration.md for full examples.
window.render_game_to_text()Returns a JSON string of the current game state. Used by game-qa and game-tester for state verification.
window.advanceTime(ms)Advances the game by N milliseconds deterministically. Used for step-based frame control in automated tests.
STEP 4 COMPLETE:
window.render_game_to_text()returns [describe JSON shape].window.advanceTime(ms)implemented with [deterministic/non-deterministic] time control.
Implement game mechanics from the design document using iterative workflow:
See references/game-patterns.md for:
STEP 5 COMPLETE: Mechanics implemented: [list each mechanic]. Remaining: [list or "none"].
Review all code for quality standards.
const and let, never varupdatePlayerPosition() not update()STEP 6 COMPLETE: No magic numbers: [confirmed/fixed N]. Naming: [confirmed/fixed N]. Error handling: [confirmed/added N guards]. Functions under 30 lines: [confirmed/refactored N].