Top-down alien shooter · qwen3-coder-flash
Using the pre-provided phaser.min.js (global Phaser), build a top-down alien shooter: move with WASD, aim and fire at waves of advancing aliens, with health, score, and increasing difficulty. Use ONLY procedurally generated graphics, no external image or audio 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
Using the pre-provided phaser.min.js (global Phaser), build a top-down alien shooter: move with WASD, aim and fire at waves of advancing aliens, with health, score, and increasing difficulty. Use ONLY procedurally generated graphics, no external image or audio assets.
```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Alien Shooter</title> <script src="phaser.min.js"></script> <style> body { margin: 0; padding: 0; background-color: #000; display: flex; justify-content: center; align-items: center; height: 100vh; font-family: 'Courier New', monospace; color: #0f0; } #game-container { position: relative; } #ui-overlay { position: absolute; top: 10px; left: 10px; z-index: 10; } #game-title { position: absolute; top: 20px; width: 100%; text-align: center; font-size: 36px; text-shadow: 0 0 10px #0f0; letter-spacing: 3px; } #game-over { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; z-index: 20; display: none; } #restart-btn { background: #003300; color: #0f0; border: 1px solid #0f0; padding: 10px 20px; font-family: 'Courier New', monospace; font-size: 18px; cursor: pointer; margin-top: 20px; transition: all 0.3s; } #restart-btn:hover { background: #006600; box-shadow: 0 0 15px #0f0; } </style> </head> <body> <div id="game-container"> <div id="game-title">ALIEN SHOOTER</div> <div id="ui-overlay"> <div>SCORE: <span id="score">0</span></div> <div>HEALTH: <span id="health">100</span></div> <div>WAVE: <span id="wave">1</span></div> </div> <div id="game-over"> <h2>GAME OVER</h2> <p>Final Score: <span id="final-score">0</span></p> <button id="restart-btn">RESTART</button> </div> </div> <script> // Game configuration const config = { type: Phaser.AUTO, width: 800, height: 600, parent: 'game-container', physics: { default: 'arcade', arcade: { gravity: { y: 0 }, debug: false } }, scene: { preload: preload, create: create, update: update } }; // Game variables let player; let cursors; let aliens; let bullets; let score = 0; let health = 100; let wave = 1; let gameActive = true; let lastShotTime = 0; let shotDelay = 150; // milliseconds let alienSpawnTimer; let alienSpeed = 100; let alienSpawnRate = 2000; // milliseconds let nextWaveTime = 0; let waveInterval = 10000; // milliseconds between waves // Create the game const game = new Phaser.Game(config); function preload() { // No assets to preload since we're using procedural graphics } function create() { // Create player sprite player = this.physics.add.sprite(400, 500, 'player'); player.setCollideWorldBounds(true); // Create a simple player shape using graphics const playerGraphics = this.make.graphics({ x: 0, y: 0 }); playerGraphics.fillStyle(0x00ff00); playerGraphics.fillTriangle(0, -15, -10, 15, 10, 15); playerGraphics.generateTexture('player', 30, 30); player.setTexture('player'); player.setScale(1.5); // Create bullets group bullets = this.physics.add.group(); bullets.enableBody = true; // Create aliens group aliens = this.physics.add.group(); // Set up keyboard controls cursors = this.input.keyboard.createCursorKeys(); const keys = this.input.keyboard.addKeys('W,A,S,D'); // Set up collision detection this.physics.add.overlap(bullets, aliens, hitAlien, null, this); this.physics.add.overlap(player, aliens, hitPlayer, null, this); // Initialize UI updateUI(); // Start spawning aliens spawnAliens(); // Set up restart button document.getElementById('restart-btn').addEventListener('click', restartGame); // Start wave timer nextWaveTime = this.time.now + waveInterval; } function update() { if (!gameActive) return; // Move player based on keys pressed if (cursors.left.isDown || Phaser.Input.Keyboard.JustDown(this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.A))) { player.setVelocityX(-160); } else if (cursors.right.isDown || Phaser.Input.Keyboard.JustDown(this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.D))) { player.setVelocityX(160); } else { player.setVelocityX(0); } if (cursors.up.isDown || Phaser.Input.Keyboard.JustDown(this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.W))) { player.setVelocityY(-160); } else if (cursors.down.isDown || Phaser.Input.Keyboard.JustDown(this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.S))) { player.setVelocityY(160); } else { player.setVelocityY(0); } // Shooting logic if (this.input.activePointer.isDown || Phaser.Input.Keyboard.JustDown(this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE))) { shoot(); } // Check for wave advancement if (this.time.now > nextWaveTime && aliens.getChildren().length === 0) { advanceWave(); } // Update alien positions aliens.children.iterate(function(alien) { if (alien.y > 650) { // Alien reached bottom alien.destroy(); health -= 10; updateUI(); if (health <= 0) { gameOver(); } } }); } function shoot() { const now = this.time.now; if (now - lastShotTime > shotDelay) { // Create bullet const bullet = bullets.create(player.x, player.y - 15, 'bullet'); // Create a simple bullet shape const bulletGraphics = this.make.graphics({ x: 0, y: 0 }); bulletGraphics.fillStyle(0x00ffff); bulletGraphics.fillCircle(0, 0, 3); bulletGraphics.generateTexture('bullet', 6, 6); bullet.setTexture('bullet'); bullet.setVelocityY(-300); bullet.setScale(1.5); lastShotTime = now; } } function spawnAliens() { if (!gameActive) return; // Create a new alien const alien = aliens.create( Phaser.Math.Between(50, 750), -30, 'alien' ); // Create a simple alien shape const alienGraphics = this.make.graphics({ x: 0, y: 0 }); alienGraphics.fillStyle(0xff0000); alienGraphics.fillCircle(0, 0, 15); alienGraphics.fillStyle(0x0000ff); alienGraphics.fillCircle(-5, -5, 4); alienGraphics.fillCircle(5, -5, 4); alienGraphics.generateTexture('alien', 30, 30); alien.setTexture('alien'); alien.setVelocityY(alienSpeed); alien.setScale(1.2); // Schedule next spawn alienSpawnTimer = this.time.delayedCall(alienSpawnRate, spawnAliens, [], this); } function hitAlien(bullet, alien) { bullet.destroy(); alien.destroy(); // Increase score score += 10; updateUI(); } function hitPlayer(player, alien) { alien.destroy(); health -= 20; updateUI(); if (health <= 0) { gameOver(); } } function updateUI() { document.getElementById('score').textContent = score; document.getElementById('health').textContent = health; document.getElementById('wave').textContent = wave; } function advanceWave() { wave++; alienSpeed += 10; alienSpawnRate = Math.max(500, alienSpawnRate - 100); nextWaveTime = game.time.now + waveInterval; // Spawn more aliens for the new wave for (let i = 0; i < wave * 3; i++) { setTimeout(() => { if (gameActive) { spawnAliens(); } }, i * 500); } updateUI(); } function gameOver() { gameActive = false; document.getElementById('final-score').textContent = score; document.getElementById('game-over').style.display = 'block'; } function restartGame() { // Reset game state score = 0; health = 100; wave = 1; gameActive = true; alienSpeed = 100; alienSpawnRate = 2000; nextWaveTime = game.time.now + waveInterval; // Clear groups bullets.clear(true, true); aliens.clear(true, true); // Reset player position player.setPosition(400, 500); // Hide game over screen document.getElementById('game-over').style.display = 'none'; // Update UI updateUI(); // Restart spawning spawnAliens(); } </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.