2.5 KiB
2.5 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Running the Game
No bundler required. Serve with any local HTTP server and open http://localhost:8080:
python3 -m http.server 8080
# or
npx serve .
Architecture
Entry Point & Scene Flow
index.html loads src/main.js as an ES6 module. Phaser is loaded via CDN (no bundler). Scene flow:
MainMenu— title screen, starts gameGameManager— readsconfig/game.json, randomly selects N mini-games for the current level, sequences through them, and manages global state (lives, current level)- Each mini-game scene — runs its level, then signals completion or failure back to
GameManager
Mini-Game Contract
Each mini-game is a self-contained Phaser Scene exported from its subdirectory. Every mini-game must implement the same interface so GameManager can plug it in without knowing its internals:
- Accept a
onCompleteandonFailcallback (passed via Phaser scene data or events) - Emit/call
onCompletewhen the level is beaten;onFailwhen a life is lost
To add a new mini-game: create a subdirectory under src/games/, implement the Scene contract, and register it in config/game.json.
Directory Structure
index.html
config/
game.json # level-to-game-count mapping, lives, active game pool
src/
main.js # Phaser game init, registers all scenes
scenes/
MainMenu.js
GameManager.js # sequences mini-games, tracks lives/level
games/
colorado-defense/
ColoradoDefense.js
config.json
code-bug-invaders/
CodeBugInvaders.js
config.json
dot-dude/
DotDude.js
config.json
smash-out/
SmashOut.js
config.json
Configuration
config/game.json— top-level settings: number of games per level, lives count, which games are in the poolsrc/games/<name>/config.json— per-game tuning: speeds, enemy counts, timing, etc.
Tech Stack & Constraints
- Phaser 3.90 — loaded via CDN, not npm
- Vanilla JS ES6 modules —
import/exportonly, no webpack/Vite/bundler - Canvas: 1600×900 with
Phaser.Scale.FITfor responsive scaling - Graphics: Vector graphics only during initial development (no sprite sheets yet)
- Controls: Arrow keys +
Ato fire for all games; mouse for aiming in Colorado Defense only - Lives: 3 lives global; game over on third loss
- Level 1: 3 randomly selected games; Level 2: 4 randomly selected games