Space Invaders · llama-4-scout
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.
This one-shot run produced no runnable artifact.
agent produced no index.html
The transcript below shows what the model did — read it to see why the one shot fell short.
transcript · 2 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.
a simple implementation of Invaders game using HTML5 canvas and JavaScript. ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Space Invaders</title> <style> /* Add some basic styling to our game */ canvas { border: 1px solid black; } </style> </head> <body> <canvas id="gameCanvas" width="800" height="600"></canvas> <script> // Get the canvas element const canvas = document.getElementById('gameCanvas'); const ctx = canvas.getContext('2d'); // Set the canvas dimensions canvas.width = 800; canvas.height = 600; // Define some colors const colors = { player: 'blue', alien: 'green', bullet: 'red', bunker: 'gray' }; // Define the player let player = { x: canvas.width / 2, y: canvas.height - 50, width: 50, height: 50, speed: 5, lives: 3, score: 0 }; // Define the aliens let aliens = []; for (let i = 0; i < 5; i++) { for (let j = 0; j < 10++) { aliens.push({ x: j * 70 + 50, y: i50 + 50, width: 50, height: 50 }); } } // Define the bullets let playerBullets = []; let alienBullets = []; // Define the bunkers let bunkers = []; for (let i = i < 4; i bunkers.push({ x: i * 200 + 100, y: canvas.height - 100, width: 50, height: 50 }); } // Main game function draw() { // Clear the canvas ctx.clearRect(0, 0, canvas.width, canvas.height); // Draw the player ctx.fillStyle = colors.player; ctx.fillRect(player.x, player.y, player.width, player.height); // Draw the aliens for (let i = 0; i < aliens.length; i++) { ctx.fillStyle = colors.alien; ctx.fillRect(aliens[i].x, aliens[i].y, aliens[i].width, aliens[i].height); } // Draw the bullets for (let i = 0; i < playerBullets.length; i++) { ctx.fillStyle = colors.bullet; ctx.fillRect(playerBullets[i].x, playerBullets[i].y, 10, 20); } (let i = 0; i < alienBullets.length; i++) { ctx.fillStyle = colors.bullet; ctx.fillRect(alienBullets[i].x, alienBullets[i].y, 10, 20); } // Draw the bunkers for (let i = 0; i < bunkers.length; i++) { ctx.fillStyle = colors.bunker; ctx.fillRect(bunkers[i].x, bunkers[i].y, bunkers[i].width, bunkers[i].height); } // Update the game state update(); } // Update the game state function update() { // Move the player bullets for (let i = playerBullets.length - 1; i >= 0; i--) { playerBullets[i].y -= 5; if (playerBullets[i].y < 0) { playerBullets.splice(i, 1); } } // Move the alien bullets for (let i = alienBullets.length - 1; i >= 0; i--) { alienBullets[i].y += 5; if (alienBullets[i].y.height) { alienBullets.splice(i, 1); } } // Move the aliens for (let i = 0; i < aliens.length; i++) { aliens[i].x += 1; if (aliens[i].x > canvas.width[i].width || aliens[i].x < 0) { for (let j = 0; j < aliens.length; j aliens[j].y += 20; aliens[j].x += aliens[i].x > canvas.width - aliens[i].width ? : 5; } } } // Check for collisions for (let i = 0; i < playerBullets.length; i++) { for (let j = 0; j < aliens.length; j++) { if (checkCollision(playerBullets[i], aliens[j])) { player.score++; playerBullets.splice(i, 1); aliens.splice(j, 1); i--; break; } } for (let j = 0; j < bunkers.length; j++) { if (checkCollision(playerBullets[i], bunkers[j])) { playerBullets.splice(i, 1); bunkers.splice(j, 1); i--; break; } } } for (let i = 0; i < alienBullets.length; i++) { if (checkCollision(alienBullets[i], player)) { player.lives--; alienBullets.splice(i, 1); i--; } for (let j = 0; j < bunkers.length; j++) { if (checkCollision(alienBullets[i], bunkers[j])) { alienBullets.splice(i, 1); bunkers.splice(j, 1); i--; break; } } } // Game over if (player.lives <= 0) { alert('Game Over! Your score: ' + player.score); player.lives = 3; player.score = 0; playerBullets = []; alienBullets = []; aliens = []; for (let i = 0; i < 5; i++) { for (let j = 0; j < 10; j++) { aliens.push({ x: j * 70 + 50, y: i * 50 + 50, width: 50, height: 50 }); } } bunkers = []; for (let i = 0; i < 4; i++) { bunkers.push({ x: i * 200 +, y: canvas.height - 100, width: 50, height: 50 }); } } // Alien fire if (Math.random() < 0.05) { let alien = aliens alienBullets.push({ x: alien.x + alien.width / 2, y: alien.y + alien.height }); } // Draw the score and lives ctx.font = '24px Arial'; ctx.fillStyle = 'black'; ctx.textAlign = 'left'; ctx.textBaseline = 'top'; ctx.fillText('Score: ' + player.score, 10, 10); ctx.textAlign = 'right'; ctx.fillText('Lives: ' + player.lives, canvas.width - 10, 10); } // Check for collision between two objects function checkCollision(obj1, obj2) { if (obj1.x + 10 > obj2.x obj1.x < obj2.x + obj2.width && .y + 20 > obj2.y && obj1.y < obj2.y + obj2.height) { return true; } return false; } // Handle keyboard input .addEventListener('keydown', (e) => { e.key === 'Arrow { player.x -= player } else if (e.key === 'ArrowRight') player.x += player.speed; } else if (e.key === ' ') { playerBullets.push({ x: player.x + player.width / 2, y: player.y }); } }); // Start the game loop setInterval(draw, 1000 / 60); </script> </body> </html> ```
TAKE IT TO CODE
This run produced no artifact — reuse the prompt with a different model or your own pi-agent run.