Explorer’s Lab › Phosphor Siege › Build log
Build log
Research and build of Phosphor Siege from a one-line brief
Researched how the 1978 arcade hardware behaved, then built an original fixed shooter around those mechanics with Vite 8, TypeScript 7, a WebGL2 CRT shader and Web Audio synthesis, plus tests and VPS deploy tooling.
Goal
Derek’s brief (BRIEF.md): an 80s-authentic browser version of a classic alien-invasion arcade game, researched for authenticity and deployable to a sub-directory of a VPS, using the latest web technology.
What was done
- Scope decision. Claude Code wouldn’t reproduce the named game’s name, sprites, sounds or exact look. It built an original game in the genre and kept the authenticity in the mechanics. It told Derek this in its first summary.
- Research. Two web searches and one read of a public annotated disassembly. The values taken from it are listed in the dossier. Anything it didn’t confirm (saucer speed, missile speeds, colour-band positions) was decided by judgement.
- Scaffold. An npm project with Vite 8.4.0 and TypeScript 7.0.2, both the latest at the time. The config is
base: './'so the build works in any sub-directory. - Engine.
- A 1-bit 224×256 frame buffer with pixel-perfect collisions.
- The one-invader-per-tick ripple march, with the edge reversal and 8 px drop applied after each full sweep.
- Rack movement pauses while an invader explodes.
- Three round-robin missile types (aimed, and two column tables), with score-based reload and the “last invader” and “saucer shares a slot” rules.
- A shot-count mystery-ship table, waves that start lower, erodible bunkers and floor, and shots that cancel each other.
- An extra life at 1,500 and a typewriter attract screen.
- Art. All sprites and the font were drawn as text pixel grids. Two first drafts (the bottom and middle invader ranks) were too close to the classic designs, so they were redrawn before any code depended on them.
- Rendering. The coloured-film band overlay, a WebGL2 CRT shader, CPU phosphor persistence, a Canvas 2D fallback and a 3:4 portrait aspect.
- Sound. Web Audio only: a square-wave march with a low-pass filter, LFSR noise explosions, and an LFO saucer warble.
- Input and the web platform. Keyboard, the Gamepad API and touch buttons. Also auto-pause when the tab is hidden, Screen Wake Lock, Fullscreen, and a PWA manifest and service worker.
- Tests. 10 Vitest headless simulation tests.
- Deploy tooling.
scripts/deploy.sh(rsync),deploy/nginx.conf,public/.htaccess,.env.exampleand a README. - Ran a local dev server for Derek and committed the work as
00d3baf, at his request.
What broke / dead ends
- Phone layout. At 375 px wide the canvas overflowed sideways, because the canvas’s built-in width pushed the CSS grid track wider. Fixed with
minmax(0, 1fr)columns,min-width: 0, and an absolutely positioned canvas sized by aResizeObserver. - First nginx snippet. It used
aliaswith nested regex locations, which nginx handles badly. It was rewritten to use the server’sroot, with theno-cacherule listed before the long-cache.jsrule sosw.jsisn’t cached for a year. - Capture tooling. A browser-pane click failed because no screenshot had been taken first, and one tap missed the canvas. Both were retried. No code changes were needed.
- Unconfirmed values. The research didn’t confirm the saucer’s speed in pixels per tick. A subagent’s unverified summary said 2 px, and the build uses 1 px per tick by judgement.
Human interventions
None beyond the brief. Derek’s only follow-ups were “can you run it in a local server” and “commit it”.
Verification
tsc --noEmitpassed.vitest run: 10 out of 10 passed.vite build: 31.4 KB JS (10.5 KB gzipped).- Served the build from a fake sub-directory (
/games/siege/) withpython3 -m http.serverand played it in Claude Code’s browser pane with a scripted key bot. Scoring, bunker erosion, floor holes and the march all worked, with no console errors. - Checked at 375×812 phone size with touch emulation. The FIRE button and tap-to-start work.
- Not verified: real phones and tablets, Safari and Firefox, a real gamepad, actual deployment to Derek’s VPS, the PWA install flow over HTTPS, and human judgement of difficulty and game feel.
Next steps
- A human playtest for difficulty, especially how fast the later waves fire.
- Possibly an optional two-player alternating mode and a cabinet backdrop image.