Web Game Foundations
Use this skill for architecture decisions or cross-cutting changes. For focused work in an established project, preserve its working boundaries and change only what the request requires.
Choose The Runtime
- Preserve the existing runtime for features and bug fixes unless it blocks the requested outcome.
- Prefer Phaser for a new sprite, tilemap, arcade, tactics, or side-view 2D game.
- Prefer plain Three.js for a new imperative 3D runtime in TypeScript or Vite.
- Prefer React Three Fiber only when React state and composition are genuine requirements.
- Keep a working Canvas, Babylon.js, PlayCanvas, or custom runtime when the user or project has already chosen it.
Stable Boundaries
- Simulation owns rules, entities, progression, timers, collisions, and saveable state.
- Rendering owns scene composition, animation playback, cameras, particles, and presentation state.
- Map keyboard, pointer, touch, and gamepad inputs to named game actions in one place.
- Keep text-heavy HUD and menus in DOM unless the visual design requires canvas or WebGL UI.
- Address assets through stable manifest keys rather than scattering file paths through gameplay code.
- Save serializable game state, not renderer objects.
- Keep debug and performance probes removable or easy to disable.
Use these boundaries in proportion to the project. A small game does not need an enterprise framework, but its rules should not become inseparable from rendering callbacks.
Multiplayer
For OhMyGame online play, use Colyseus rooms and WebSocket with server-authoritative rules. Call multiplayer_setup when available for local tests; it starts a daemon-owned loopback backend and writes src/ohmygame/client.js, an integration guide, multiplayer.json, and public/manifest.json. Read that guide before implementing the game. No cloud deployment is needed for local validation.
Choose the actual server rules adapter: gomoku, stones, or arena. Other rules require a registered server adapter; an SDK connection does not turn arbitrary local game rules into multiplayer. If the service, adapter, or tool is unavailable, report the missing setup. Do not silently use PeerJS, WebRTC, public signaling/STUN/TURN servers, or client-authoritative boards as substitutes. Honor an explicitly requested alternative stack and explain that the platform's Colyseus publishing checks do not support it.
Load the runtime manifest, send player intent through the SDK, and render authoritative snapshots. Handle room creation, joining, waiting for another player, rejected commands, disconnect, refresh, and connection timeout. Test two independent guests, including an invalid action and reconnect. Keep the SDK's default localStorage identity: one browser is one player, so test the second player in a private window or another browser, never with per-tab storage. Local rooms end when the daemon stops; rerun setup after restarting it. Public publishing requires a separately hosted HTTPS backend and an immutable deployment whose rules and configuration match the game.
Before Implementation
For a new or substantially changed game, establish:
- player fantasy and primary verbs
- core loop, success, failure, and restart behavior
- camera and input model
- simulation and rendering ownership
- asset organization and loading states
- HUD and menu surfaces
- save, debug, and performance expectations
Once the stack is clear, continue with the relevant runtime skill rather than expanding the architecture indefinitely.
1---2name: web-game-foundations3description: Set or repair browser-game architecture, including engine choice, game-state ownership, input, assets, save data, debugging, and performance boundaries.4metadata:5 source: https://skillmd.com/skills/whitetowerai/web-game-foundations6---78# Web Game Foundations910Use this skill for architecture decisions or cross-cutting changes. For focused work in an established project, preserve its working boundaries and change only what the request requires.1112## Choose The Runtime1314- Preserve the existing runtime for features and bug fixes unless it blocks the requested outcome.15- Prefer Phaser for a new sprite, tilemap, arcade, tactics, or side-view 2D game.16- Prefer plain Three.js for a new imperative 3D runtime in TypeScript or Vite.17- Prefer React Three Fiber only when React state and composition are genuine requirements.18- Keep a working Canvas, Babylon.js, PlayCanvas, or custom runtime when the user or project has already chosen it.1920## Stable Boundaries2122- Simulation owns rules, entities, progression, timers, collisions, and saveable state.23- Rendering owns scene composition, animation playback, cameras, particles, and presentation state.24- Map keyboard, pointer, touch, and gamepad inputs to named game actions in one place.25- Keep text-heavy HUD and menus in DOM unless the visual design requires canvas or WebGL UI.26- Address assets through stable manifest keys rather than scattering file paths through gameplay code.27- Save serializable game state, not renderer objects.28- Keep debug and performance probes removable or easy to disable.2930Use these boundaries in proportion to the project. A small game does not need an enterprise framework, but its rules should not become inseparable from rendering callbacks.3132## Multiplayer3334For OhMyGame online play, use Colyseus rooms and WebSocket with server-authoritative rules. Call `multiplayer_setup` when available for local tests; it starts a daemon-owned loopback backend and writes `src/ohmygame/client.js`, an integration guide, `multiplayer.json`, and `public/manifest.json`. Read that guide before implementing the game. No cloud deployment is needed for local validation.3536Choose the actual server rules adapter: `gomoku`, `stones`, or `arena`. Other rules require a registered server adapter; an SDK connection does not turn arbitrary local game rules into multiplayer. If the service, adapter, or tool is unavailable, report the missing setup. Do not silently use PeerJS, WebRTC, public signaling/STUN/TURN servers, or client-authoritative boards as substitutes. Honor an explicitly requested alternative stack and explain that the platform's Colyseus publishing checks do not support it.3738Load the runtime manifest, send player intent through the SDK, and render authoritative snapshots. Handle room creation, joining, waiting for another player, rejected commands, disconnect, refresh, and connection timeout. Test two independent guests, including an invalid action and reconnect. Keep the SDK's default localStorage identity: one browser is one player, so test the second player in a private window or another browser, never with per-tab storage. Local rooms end when the daemon stops; rerun setup after restarting it. Public publishing requires a separately hosted HTTPS backend and an immutable deployment whose rules and configuration match the game.3940## Before Implementation4142For a new or substantially changed game, establish:4344- player fantasy and primary verbs45- core loop, success, failure, and restart behavior46- camera and input model47- simulation and rendering ownership48- asset organization and loading states49- HUD and menu surfaces50- save, debug, and performance expectations5152Once the stack is clear, continue with the relevant runtime skill rather than expanding the architecture indefinitely.