(Body Snatcher) Pass 4

This commit is contained in:
AlexKucera committed 2026-08-13 15:23:35 +02:00
1 parent 2c1d0fc4d0
commit 0a3035ead4
36 files changed
+7693

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
You are implementing PHASE 1 ONLY of the game "Body Snatcher" in a single file: index.html (in this same directory). @AGENTS.md is the FULL game spec — read it completely before writing anything. @verify.js is the automated test harness and the exact contract for this phase; run `node verify.js 1` and make it pass (exit 0).
SCOPE for Phase 1 — build ONLY these systems (later phases add the rest, so keep the code organized and extensible but do not implement enemies/posession/shop/procgen/audio yet):
1. Single index.html, HTML5 Canvas 800x576 + a HUD bar, ALL CSS and JS inline, ZERO external dependencies (no CDN, no src=, no import/export). Open the file in a browser and it works.
2. A game loop. The core model is ONE-TILE-PER-TURN and deterministic. Expose window.GAME.tick(n) which advances the simulation exactly n turns. A real-time loop may call tick(1) on a ~600ms cadence for liveliness, but NEVER tie core state to wall-clock — the harness drives everything via tick(n) and input().
3. A 25x18 tile grid. Store it on window.GAME.grid as grid[y][x]. Each cell is a NUMBER: 0=floor, 1=wall, 2=door, 3=exit-stairs, 4=shop-pad, 5=chest. (For this phase use a hand-authored static test dungeon with rooms, walls, and at least one exit tile.)
4. Tile rendering: dark beveled stone walls (gradients, mortar/crack lines, soft drop shadow onto floor), subtly lit floor flagstones, a glowing runic exit, warm torch color grade + soft vignette, faint grid lines. NO flat single-rect placeholders — layered/shaded canvas primitives per AGENTS.md §Visual Style.
5. Ghost player. window.GAME.player = { x, y, ghost:true, timer, host:null, facing:{x,y} }. Movement via WASD / Arrow keys, one tile per turn, BLOCKED by walls. Snappy ~85ms interpolation between tiles; hold-to-move continuous at the turn cadence (presentation only).
6. Ghost timer: timer is a NUMBER of SECONDS. Base cap = 15. After a fresh run (newRun()) the timer equals the cap (15). tick(n) decrements it deterministically (e.g. by n * 0.6). When it reaches 0 the game is lost (you may stub the lost screen for now; full lose is Phase 5).
7. Fog of war: radial soft-gradient visibility around the player; explored-but-unseen tiles dimmed with a cool memory tint. Unexplored tiles hidden.
8. HUD at top showing current body HP (N/A as ghost), the ghost timer, essence (0 for now), floor number (1), and a contextual SPACE hint ("SPACE: Possess" while ghost).
9. TITLE screen shown on load. GAME.start() must reset to the TITLE screen and the game MUST NOT auto-start into play (wait for Enter). The title screen MUST visibly explain the controls: WASD/Arrows (move), SPACE (possess/attack), Q/E (rotate facing), X (abandon host), ENTER (start/confirm), ESC (pause). Pressing ENTER starts a run (state -> "playing"). Pressing lowercase 'l' opens an ENEMY LEGEND / BESTIARY overlay that lists each enemy with its color/shape, its enemy behavior, and its possessed player kit (HP/damage/special). For Phase 1 you only need the 3 enemies that exist later (Brute, Skitterer, Sentinel) described, but structure the bestiary as data so all 12 can be added later.
EXPOSE on window.GAME exactly (the harness reads these — see @verify.js):
state // one of: title, playing, possessed, shop, paused, won, lost
player // { x, y, ghost, timer(seconds), host, facing:{x,y} }
grid // grid[y][x] numeric tiles
floor // 1
essence // 0
enemies // [] for now
projectiles // [] for now
upgrades // {}
achievements // {}
log // []
start() // -> title screen, no auto-start
input(key) // accept ArrowUp/Down/Left/Right, w a s d, ' ' and 'Space', q e, x, Enter, Escape, l
tick(n) // deterministic; advances n turns; decrements ghost timer
newRun() // start a fresh floor-1 run with the test dungeon; player is a ghost at spawn; timer reset to cap (15); state 'playing'
setFloor(n) // (stub OK for now, but must not throw)
spawn(type,x,y) // (stub OK for now, but must not throw)
CONTRACT DETAILS the harness asserts (match them exactly):
- After GAME.start(), state === 'title'.
- After newRun(), player.timer >= 15.
- grid contains both wall (1) and floor (0) tiles.
- input('ArrowRight') etc. moves the ghost; the ghost never lands on a wall tile.
- The title screen canvas text (drawn via ctx.fillText) or DOM text includes the words: wasd, arrow, space, q, e, enter, esc.
- Pressing 'l' then rendering shows a bestiary containing the words brute, skitterer, sentinel, and an HP/damage description.
CRITICAL: The game MUST NOT crash if Canvas getContext('2d') returns a mock with no-op methods, and MUST NOT crash if AudioContext is a mock constructor. The harness mocks these. Do NOT call any real browser-only API at load time without guarding.
When done, run `node verify.js 1` yourself. Fix every failure until it prints "PHASE 1 PASSED" and exits 0. Do not rewrite from scratch on retry — make targeted fixes. Write LESS code, not more; no stubs/TODOs/placeholders; everything you ship works.