Space Invaders · claude-sonnet-5.5
Output generated Cost / run $0.1069 Runtime 51.5s
Prompt for this run
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.
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
METRICS
Transcript · 12 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.
/tmp/job-Zb8ebY/index.html (7376 bytes){"action":"reload"}Successfully wrote to /tmp/job-Zb8ebY/index.html
Frame 1, +1ms
[Browser image supplied to model]
{"console":["warning: An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing."],"dom":"←/→ or A/D move · SPACE shoot · Enter start/restart · P pause","images":"attached"}
thinking
The lives display shows one fewer icon than actual lives since one is reserved, so with 3 lives it'll show 2 icons—that seems fine. Let me test the gameplay quickly.
{"action":"key","text":"Enter"}{"action":"key","text":"Space"}{"action":"screenshot"}Frame 1, +0ms
[Browser image supplied to model]
{"console":["warning: An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing."],"dom":"←/→ or A/D move · SPACE shoot · Enter start/restart · P pause","images":"attached"}
Frame 1, +0ms
[Browser image supplied to model]
{"console":["warning: An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing."],"dom":"←/→ or A/D move · SPACE shoot · Enter start/restart · P pause","images":"attached"}
Frame 1, +0ms
[Browser image supplied to model]
{"console":["warning: An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing."],"dom":"←/→ or A/D move · SPACE shoot · Enter start/restart · P pause","images":"attached"}
thinking
The game doesn't seem to be advancing between screenshots—the aliens aren't moving, which makes me wonder if the screenshots are just instant frame grabs. Lives display shows 2 icons for 3 lives which seems fine, and key events are likely instantaneous keydown+keyup pairs, so I should test with actual motion.
{"action":"motion"}Frame 1, +0ms
[Browser image supplied to model]
Frame 2, +587ms
[Browser image supplied to model]
Frame 3, +1172ms
[Browser image supplied to model]
Frame 4, +1786ms
[Browser image supplied to model]
{"console":["warning: An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing."],"dom":"←/→ or A/D move · SPACE shoot · Enter start/restart · P pause","images":"attached"}
I've built the game in `/tmp/job-Zb8ebY/index.html`. I watched it run in the browser, but I didn't test everything. **What I saw working:** - **Start:** pressing Enter starts a game. - **Aliens:** the three alien types animate and march sideways in formation. - **Bombs:** aliens fire bombs back at the player. - **Bunkers:** the bombs chip away at the bunkers. - **Display:** the score, high score, level and lives show on screen, and there were no console errors. **Not tested:** - **Player shooting:** I sent one Space keypress, but the score stayed at 0 and I didn't confirm a hit on an alien. - **Movement:** I never tried moving the cannon left and right. - **Lives:** no bomb reached the cannon, so losing a life isn't confirmed. - **Other behavior:** I also didn't check game over, restart, pause, the bonus ship, or clearing a wave. **Controls:** - **Move:** ←/→ or A/D - **Shoot:** Space (one shot on screen at a time) - **Start or restart:** Enter - **Pause:** P **Rules:** - **Score:** the top row is worth 30 points, the next two rows 20, and the bottom two 10. A red bonus ship that crosses the top occasionally is worth 50 to 300. - **Lives:** you start with three. - **Difficulty:** the aliens speed up as their numbers drop. Each new wave starts lower and fires more bombs. - **Game over:** you lose if the aliens get too low or you run out of lives.