Space Invaders · qwen3.8-2.4t-a95b
Build a playable Space Invaders game on a canvas: a player cannon that moves and shoots, a descending grid of aliens that advance and fire back, destructible bunkers, score, and lives. Procedural graphics only, no external assets.
transcript · 6 messages
Build a playable Space Invaders game on a canvas: a player cannon that moves and shoots, a descending grid of aliens that advance and fire back, destructible bunkers, score, and lives. Procedural graphics only, no external assets.
thinking
Build a complete Space Invaders in a single index.html. Let's write a solid implementation: canvas, player, aliens in a grid (3 types), alien movement + descent + shooting, destructible pixel-based bunkers, score, lives, UFO if possible. Procedural sprites via pixelmaps drawn to canvas. Keyboard controls. Game states: start, playing, game over, win/next wave. Bunkers: represent each bunker as a small grid of destructible cells. Bullets erode the cells. Alien animation: 2 frames, toggle. Speed increases as the number decreases. Let's write it carefully and concisely.
/tmp/ws/index.html (23808 bytes)Successfully wrote 23808 bytes to /tmp/ws/index.html
thinking
Quick sanity check: does a JS syntax issue exist? Let's quickly verify with node (extract the script). Also, check for logical issues:
- `drawText('' ...)` inside PLAYER_DYING is a harmless no-op; no problem.
- Aliens only march horizontally while alive; no problem.
- Collisions: player bullets and bunkers — in the classic version, player bullets don't collide with their own bunkers, but blocking both is fine too.
- PLAYER_DYING state: aliens pause (no updateAliens), no problem.
Let's extract the script and verify the syntax with node.
Let me verify the JavaScript has no syntax errors:
{"command":"cd /tmp/ws && node -e \"\nconst html = require('fs').readFileSync('index.html','utf8');\nconst m = html.match(/<script>([\\s\\S]JS syntax OK, script length: 22723 -rw-r--r--. 1 node node 23816 Aug 13 01:35 index.html
thinking
The environment may not have a browser, but a simple smoke test using jsdom isn't necessary. Syntax checking alone is sufficient. Done.
Done — `/tmp/ws/index.html` is a complete, self-contained Space Invaders game. Syntax verified, no external assets or network requests. **Features:** 🎮 **Gameplay** - Player cannon moves with ←/→ or A/D, shoots with Space (2-bullet limit + cooldown, classic style) - 5×11 grid of aliens in 3 types (squid 30pts, crab 20pts, octopus 10pts) that march side-to-side, drop down at the edges, and accelerate as their numbers dwindle - Aliens fire back with zigzag bolts — some aimed at the player - Mystery UFO flies across the top for 50–300 bonus points - 4 destructible bunkers: cell-based erosion with irregular blast craters, eaten from both sides, and wiped out if aliens march over them - Score, hi-score, lives (3), wave counter — waves spawn lower and faster - Win a wave → next wave; lose all lives → game over; aliens reaching the ground = instant loss 🎨 **Procedural graphics only** - All sprites (aliens with 2-frame animation, cannon, UFO) drawn from pixel maps onto the canvas - Particle explosions, twinkling starfield, pulsing UFO glow, floating score popups, retro green CRT-style glow via CSS 🔊 **Procedural audio** — Web Audio API square/sawtooth blips for shooting, kills, the classic marching thump, and explosions (no audio files) **Controls:** Enter to start/restart · Space to shoot · P to pause
TAKE IT TO CODE
A single self-contained HTML file — copy it and open in any browser, or reuse the prompt with your own pi-agent run.
RUN
EVALUATION
Space Invaders with start menu, alien grid, bunkers, cannon, and shooting all functioning via keyboard input.
Vision grade · anthropic/claude-sonnet-5
MEASUREMENTS
Raw readings from the capture, not a verdict — the grade above is the only judgement. Percentages are how much of the screen changed; the measure under-reports sparse motion on a dark background.