Space Invaders · hy3-preview
Output generated Cost / run $0.0012 Runtime 70.7s
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 · 4 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
The user wants me to build a Space Invaders game as a single-page web app in one self-contained index.html file. The requirements are: 1. Player cannon that moves and shoots 2. Descending grid of aliens that advance and fire back 3. Destructible bunkers 4. Score and lives 5. Procedural graphics only, no external assets 6. All in one index.html file with inline CSS and JS 7. No external resources, CDNs, or network requests I need to create a complete Space Invaders game using HTML5 Canvas. Let me plan the structure: - HTML structure with canvas element - CSS for basic styling (centering, background) - JavaScript with: - Game state management - Player cannon (movement with arrow keys, shooting with space) - Alien grid (movement patterns, shooting) - Bunkers (destructible with bullets) - Collision detection - Score and lives display - Game loop I'll write this all in one file
I'll create a complete Space Invaders game in a single self-contained HTML file with procedural graphics, no external assets.
/workspace/index.html (10010 bytes)Successfully wrote 10010 bytes to /workspace/index.html
thinking
The user asked me to build a playable Space Invaders game, and I've created a complete single-page web app in index.html with all the required features: 1. Player cannon that moves (arrow keys) and shoots (spacebar) 2. Descending grid of aliens that advance and fire back 3. Destructible bunkers 4. Score and lives display 5. Procedural graphics only - no external assets The game includes: - Canvas-based rendering with procedural alien shapes (3 different types) - Player movement with arrow keys - Shooting with spacebar (max 3 bullets on screen) - Alien AI that moves side to side, drops down, and shoots back - Destructible bunkers made of pixel grids - Collision detection between bullets, aliens, bunkers, and player - Score tracking and lives system - Level progression when all aliens are destroyed - Game over state with restart option (R key) - Pause functionality (P key) The file is completely self-contained with no external resources, CDNs, or network requests. All CSS is in a <style> tag, all JS is in a <script> tag, and the game runs fully sandboxed. Let me verify the file was created properly by reading it back
The Space Invaders game has been created in `/workspace/index.html`. Here's what's included: **Features:** - **Player cannon** - Move with arrow keys, shoot with spacebar (max 3 bullets on screen) - **Alien grid** - 5 rows × 10 columns of 3 alien types with procedural pixel art - **Alien behavior** - Sweep side-to-side, drop down when hitting edges, shoot back randomly - **Destructible bunkers** - 4 bunkers made of destructible pixel grids - **Score & lives** - Score display, 3 lives, game over detection - **Level progression** - Aliens speed up as fewer remain, new level when all destroyed - **Controls** - P to pause, R to restart after game over **Procedural graphics:** - 3 distinct alien designs (squid, crab, octopus) drawn with rectangles - Player cannon with base, barrel, and treads - Bunkers as pixel grids with arch cutouts - All colors defined in code, no external assets Open `index.html` in a browser to play!