From 4a18e206615a850e42fbc041ad560b309203af76 Mon Sep 17 00:00:00 2001 From: Eric Ratliff Date: Thu, 26 Jun 2025 00:29:57 -0500 Subject: [PATCH] Now with cool theme --- index.html | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++- sketch.js | 20 +++++--- 2 files changed, 154 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 1e985cb..21591da 100644 --- a/index.html +++ b/index.html @@ -1,7 +1,9 @@ - + - Asteroids Game + + + Retro Asteroids @@ -11,7 +13,145 @@ + + +

Retro Asteroids

+ +
+

W/Up: Thrust

+

A/Left: Rotate Left

+

D/Right: Rotate Right

+

Space: Shoot

+

K: Kid Mode

+

R: Restart

+

White: 10pts | Gold: 50pts

+

Pizza: 20pts | Burger: 10pts

+

Cyan: Shield | Green: Quad-Shot

+
+ \ No newline at end of file diff --git a/sketch.js b/sketch.js index 85e4734..be6fa0a 100644 --- a/sketch.js +++ b/sketch.js @@ -5,7 +5,7 @@ let hamburgers = []; let bullets = []; let shieldOrb = null; let greenOrb = null; -let lives = 30; +let lives = 3; let score = 0; let gameOver = false; let lastShieldSpawn = 0; @@ -13,7 +13,7 @@ let lastGreenSpawn = 0; let pizzaImg, hamburgerImg; let level = 1; let initialObjects = 5; -let kidMode = true; +let kidMode = false; function preload() { pizzaImg = loadImage('pizza.png', () => console.log('Pizza image loaded'), () => console.error('Failed to load pizza.png')); @@ -21,7 +21,7 @@ function preload() { } function setup() { - createCanvas(800, 600); + createCanvas(800, 600, P2D, 'gameCanvas'); window.kidMode = kidMode; // Set global kidMode before spawning ship = new Ship(); spawnObjects(initialObjects); @@ -231,16 +231,20 @@ function keyPressed() { if (keyCode === 32) { // Spacebar to shoot if (ship.quadShotActive) { // Fire in four directions: forward, backward, left, right - bullets.push(new Bullet(ship.pos, ship.heading)); - bullets.push(new Bullet(ship.pos, ship.heading + PI)); - bullets.push(new Bullet(ship.pos, ship.heading - PI / 2)); - bullets.push(new Bullet(ship.pos, ship.heading + PI / 2)); + gun_count = 4 + circle_radians = 2.0 * Math.PI + angle_between = circle_radians / gun_count + + for (let gun_index = 0; gun_index < gun_count; gun_index++) { + gun_angle = gun_index * angle_between + bullets.push(new Bullet(ship.pos, gun_angle)); + } } else { bullets.push(new Bullet(ship.pos, ship.heading)); } } if (keyCode === 82 && gameOver) { // R to restart - lives = 30; + lives = 3; score = 0; level = 1; initialObjects = 5;