oneshotlm
Compare all models on this prompt →

Asteroids · deepseek-r1-0528

Build a playable Asteroids game on a canvas: a thrust-and-rotate vector ship that shoots and wraps around the screen edges, splitting asteroids into smaller pieces, with score and lives. Procedural vector graphics only, no external assets.

⛨ sandboxed Open in new tab ↗
transcript · 4 messages
user

Build a playable Asteroids game on a canvas: a thrust-and-rotate vector ship that shoots and wraps around the screen edges, splitting asteroids into smaller pieces, with score and lives. Procedural vector graphics only, no external assets.

assistant
thinking
We are building a single-page web app for an Asteroids game. We'll write everything into one self-contained index.html file.
 The game will use HTML5 Canvas for drawing and JavaScript for game logic.

 Requirements:
 1. A spaceship that can rotate left/right, thrust forward, and shoot bullets.
 2. The ship and bullets wrap around screen edges.
 3. Asteroids that float and split into smaller asteroids when shot.
 4. Score and lives display.
 5. Procedural vector graphics (using canvas paths).

 We'll structure:
  - HTML: minimal, just a canvas and maybe a div for score.
  - CSS: to center canvas, set background, etc.
  - JavaScript: game logic, including:
      * Game state (ship, asteroids, bullets, score, lives)
      * Input handling (keyboard for rotate, thrust, shoot)
      * Update and draw loop

 Important mechanics:
  - Ship: has position, velocity, rotation angle. Thrust adds acceleration in the direction of rotation.
  - Bullets: shot from ship, travel straight until they go off-screen or hit an asteroid. Have a lifetime.
  - Asteroids: have position, velocity, size (large, medium, small). When hit, split into two smaller ones (or disappear if small) and add score.

 Implementation outline:

  We'll have a Game object that contains:
    this.ship = new Ship(...);
    this.asteroids = []; // array of Asteroid objects
    this.bullets = [];   // array of Bullet objects
    this.score = 0;
    this.lives = 3;

  Classes:
    Ship: 
        constructor(x, y, width, height) { ... }
        rotate(angle) { ... } // change rotation
        thrust(power) { ... } // apply thrust in current direction
        shoot() { ... } // creates a bullet

    Asteroid:
        constructor(x, y, size) { ... } // size: 0=big, 1=medium, 2=small
        // when hit, if size<2, split into two smaller ones with new velocities

    Bullet:
        constructor(x, y, direction, speed) { ... }
        update() { ... } // move and decrement lifetime

  Game loop:
    function update() {
        Update ship (apply thrust, move, wrap around)
        Update asteroids (move, wrap)
        Update bullets (move, wrap, check for off-screen and collisions)

        Check collisions: bullet vs asteroid, ship vs asteroid

        If ship is hit: explode, lose life, reset ship (with invincibility for a few seconds)

        Remove out-of-bound bullets and exploded asteroids.

        If no asteroids, spawn a new wave.

        Then requestAnimationFrame again.
    }

  Drawing:
    Use canvas 2d context. Draw lines to represent everything.

  Since we are writing to a single file, we'll have an HTML canvas element, and then a script tag with all JavaScript.

  Let's write the index.html:

<!DOCTYPE html>
<html>
<head>
    <title>Asteroids</title>
    <style>
        body { 
            margin: 0; 
            background: #000; 
            overflow: hidden;
            display: flex;
            flex-direction: column;
            align-items: center;
            color: white;
            font-family: monospace;
        }
        canvas { 
            background: #000; 
        }
        #scoreBoard {
            position: absolute;
            top: 10px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 24px;
        }
    </style>
</head>
<body>
    <div id="scoreBoard">Score: <span id="score">0</span> | Lives: <span id="lives">3</span></div>
    <canvas id="gameCanvas"></canvas>
    <script>
        // Game code here
    </script>
</body>
</html>

  Then we'll fill in the JavaScript:

  Constants:
    const WIDTH = 800;
    const HEIGHT = 600;

  Get canvas element and set dimensions.

  We'll define:
   - Ship properties: position, velocity, angle, rotation speed, thrust force, etc.
   - Bullet properties: speed, lifetime
   - Asteroid properties: size and speeds

  We'll use radians for angles.

  Important: We'll use a key state object to track which keys are pressed (left, right, up, space).

  This will be a long script, so we'll break into:

    class Ship { ... }
    class Asteroid { ... }
    class Bullet { ... }

    const Game = {
        init() { ... },
        update() { ... },
        draw() { ... },
        ... other methods
    }

  Steps:

    1. Setup canvas and context.
    2. Add event listeners for keydown and keyup to update key state.
    3. Initialize game state.
    4. Start the game loop.

  Due to the complexity, we'll write a complete but minimal version. We may not implement all features at first pass, but aim for:
    - Ship movement and rotation
    - Shooting
    - Asteroids that split
    - Collision detection (simple circle-based for now)
    - Lives and score

  Let's start writing.

  Important: This must run entirely offline, so no external resources.

  We'll write the entire code in one go and output to index.html.

  However, note: the tool requires the entire file content at once. We can generate the HTML with embedded CSS and JavaScript.

  We'll write the entire HTML content in the `write` tool call.

I'll create a self-contained Asteroids game using HTML5 Canvas with vector graphics for all elements. The game will include ship mechanics (rotation and thrust), asteroids that split into smaller pieces, shooting, wrapping around edges, scoring, and lives. Here's the complete `index.html` file:

write index.html (18616 bytes)
toolResult

Successfully wrote 18616 bytes to index.html

assistant
thinking
We are building a self-contained Asteroids game in a single HTML file.
 We'll have:
   - A canvas for drawing the game
   - Vector graphics: ship (triangle), asteroids (polygons), bullets (circles)
   - Ship controls: rotate left/right, thrust, fire bullets
   - Asteroids break into smaller pieces when shot
   - Screen wrapping for all objects
   - Score and lives display
   - Game over and start screens

 Steps:
   1. Write the HTML structure with a canvas and UI elements for score, lives, start and game over screens.
   2. Style the game with CSS (within a <style> tag).
   3. Write JavaScript (within a <script> tag) to implement the game.

 The JavaScript will include:
   - Classes for Ship, Asteroid, Bullet.
   - Game state: score, lives, arrays for asteroids and bullets.
   - Input handling for arrow keys and space.
   - Collision detection (circle-based for simplicity).
   - Screen wrapping.
   - Game loop: update and draw.

 Important: Everything in one file, no external resources.

 Let's create the index.html file.

I've created a self-contained Asteroids game in a single HTML file with the following features: 1. **Game elements**: - Player ship with thrust and rotation mechanics - Procedurally generated asteroids with different sizes - Ship bullets for destroying asteroids - Particle effects for explosions 2. **Game mechanics**: - Asteroids split into smaller pieces when hit - Screen wrapping at all edges - Score system with point values for different asteroid sizes - Lives system with ship respawn and invulnerability period 3. **User interface**: - Score and lives display - Start screen with instructions - Game over screen with final score - Control indicators during gameplay 4. **Controls**: - Arrow keys: Rotate (left/right), thrust (up) - Spacebar: Fire - Enter/Return key: Restart after game over The game uses pure CSS, HTML, and JavaScript with no external dependencies - all graphics are procedurally generated using canvas vector drawing techniques. The file includes: - CSS in a `<style>` block - Game logic in a `<script>` block - Vector classes, physics, and collision detection - Sound effects generated with the Web Audio API Would you like me to make any specific adjustments to the gameplay mechanics or visual style?

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

modeldeepseek-r1-0528
vendorDeepSeek
harnesspi-agent
generated2026-08-01

EVALUATION

2/5 partial

Stuck on start menu screen; clicking START GAME button never triggers gameplay in any tested 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.

idle motion0.0%
on click0.0%
on drag0.0%
on wheel0.0%
on enter + space0.0%
on arrow keys0.0%
on w/a/s/d0.0%
frame spread10.5 / 255
console errors0
js errors none

METRICS

runtime292.2s
tokens in7.8k
tokens out6.5k
cached0
cost / run$0.0179