game-client
Builds the browser client of a game in TypeScript under Bun, on plain Canvas/WebGL, Phaser, PixiJS, or Three.js and React Three Fiber: choosing the stack, the…
от fcsouza★ 29 звёзд на GitHub
Установить game-client в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Game Client
The client draws the world and collects input. In a multiplayer game the server owns the state (game-backend-architecture) and game-state-sync owns prediction, reconciliation and interpolation. This skill owns everything between those and the screen.
Checked against phaser 4.2.1, pixi.js 8.23.0, three 0.187.0 and @react-three/fiber 9.8.2 (bun pm view <pkg> version, 2026-11-14). An agent trained on an older major writes code that no longer runs; each stack's reference file lists those traps.
Choose the stack
The "what it is" column uses each project's own words. The "fits" and "avoid" columns are this skill's rule.
| Stack | What it is | Fits when | Avoid when |
|---|---|---|---|
| Plain web (Canvas 2D, WebGL2, WebGPU) | Browser APIs; you write the loop, input, loader and batcher | Few sprites, a custom renderer, a tool, a tight bundle | You find yourself writing a sprite batcher or scene graph |
| Phaser 4 | "A fast, free, and fun open source HTML5 game framework" with scenes, a loader, Arcade and Matter physics, input, cameras, tilemaps, tweens | A 2D game where you want the engine to own scenes, input and physics | You need 3D (v4 removed Mesh and Plane), or only a renderer under your own loop |
| PixiJS 8 | "Just a rendering engine" for 2D; sound, UI and layout are add-ons | A 2D game where you own the structure and want a fast batched renderer | You want scenes, physics and gamepad input built in |
| Three.js | "An easy-to-use, lightweight, cross-browser, general-purpose 3D library" | 3D with many server entities updated every snapshot | A 2D game |
| React Three Fiber | "A React renderer for three.js" | 3D inside an existing React app, mostly long-lived objects | Entities that spawn and despawn every snapshot (mounting compiles materials) |
Load one reference file for the chosen stack and skip the others.
Set up with Bun and TypeScript
- Plain web:
bun ./index.htmlserves and bundles the page with hot reloading;bun build ./index.html --outdir=distbuilds it. Details inreferences/web.md. - Phaser and PixiJS: scaffold with
bun create @phaserjs/game@latestorbun create pixi.js my-app --template bundler-vite. Their templates bundle with Vite; keep Vite and use Bun as package manager and runtime. No vendor source covers Bun's own bundler, so this is this skill's rule. - Three.js: install
threeand@types/threeat the same version. R3F: add@react-three/fiberand match React's major (fiber 9 needs React 19). - TypeScript: browser code needs
"DOM"inlib. Bun's recommended tsconfig lists only"ESNext". Give the client its own tsconfig so server code does not see DOM globals (this skill's rule).
Loop and timing
- The simulation runs on a fixed step.
ClientGameLoopingame-state-syncowns it: an accumulator overrequestAnimationFrame, a 250 ms cap per frame, prediction on each tick, and analphabetween the last two ticks. Do not write a second fixed-step loop. requestAnimationFramefollows the display rate, so a 120 Hz screen calls it twice as often as a 60 Hz one. Anything moved per frame moves by elapsed time, never a fixed amount.- Which loop owns the frame (this skill's rule):
- Plain web:
ClientGameLoopdoes. Set itsonRender(state, alpha)and draw there. - Phaser, PixiJS, Three.js, R3F: the engine runs the only frame loop. Never call
ClientGameLoop.start()and leaveonRenderunset. In the engine's per-frame hook, before it renders, callloop.step(now): it runs the due fixed ticks and returns the alpha. Then readloop.getRenderState()(previous and current state by reference, no copy) and the snapshot bracket fromgame-state-sync, and write transforms onto display objects. Each reference file names the hook.
- Plain web:
- The renderer reads state and never writes it. The WebSocket handler writes server state into the loop (
handleServerUpdate) and never touches display objects.
Pause and resync when the tab is hidden
Most browsers stop requestAnimationFrame in a background tab, while the server keeps simulating. Simulating the whole gap on return "can be a problem for long drops" (MDN). This skill's rule:
- On
visibilitychangeto hidden: stop the client loop, clear held input, suspend audio. - On visible: do not replay the gap. Drop stale interpolation snapshots, request a full snapshot, then restart the loop. When the snapshot carrying the server tick arrives, align the tick with
syncTick;handleServerUpdatealready adopts the server's tick when the client is behind.ClientGameLoop.start()resets the frame clock and the accumulator, so the first frame back runs no burst of ticks.
boilerplate/visibility-resync.ts does this for any loop with start() and stop(). In engine-driven mode, pass it gate = engineDrivenLoop(loop) from the same file and write the engine callback as if (!gate.paused) loop.step(now). The gate pauses stepping while the tab is hidden and during the resync, and res
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- boilerplate/audio-unlock.ts
- boilerplate/canvas-size.ts
- boilerplate/input-manager.ts
- boilerplate/visibility-resync.ts
- references/phaser.md
- references/pixijs.md
- references/sources.md
- references/three.md
- references/web.md
FAQ
Что делает скилл game-client?
Builds the browser client of a game in TypeScript under Bun, on plain Canvas/WebGL, Phaser, PixiJS, or Three.js and React Three Fiber: choosing the stack, the frame loop, hidden-tab pause and resync, keyboard, pointer, touch and gamepad input, audio unlock, canvas sizing, context loss, asset cleanup and performance budgets. Use when starting or fixing the part of a web game that runs in the player's browser: picking a rendering stack, wiring input or the render loop, a blurry or stretched canvas, silent audio, a game that jumps or leaks after switching tabs or scenes, or code written for Phaser 3, PixiJS 7 or an older three.js.
Как установить скилл game-client?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл game-client запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…