From 681feab14828a6d434db3a7893d244466b46923e Mon Sep 17 00:00:00 2001 From: Eric Ratliff Date: Wed, 25 Jun 2025 22:55:16 -0500 Subject: [PATCH] even better --- sketch.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/sketch.js b/sketch.js index 2e85b8d..feb710a 100644 --- a/sketch.js +++ b/sketch.js @@ -5,7 +5,7 @@ let hamburgers = []; let bullets = []; let shieldOrb = null; let greenOrb = null; -let lives = 3; +let lives = 100; let score = 0; let gameOver = false; let lastShieldSpawn = 0; @@ -27,11 +27,16 @@ function setup() { function spawnObjects(numObjects) { for (let i = 0; i < numObjects; i++) { - if (random() < 0.15) { + let rand = random(); + if (rand < 0.25) { pizzas.push(new Pizza()); console.log(`Spawned pizza at level ${level}, total pizzas: ${pizzas.length}`); + } else if (rand < 0.25) { + asteroids.push(new Asteroid(null, null, true)); // Golden asteroid + console.log(`Spawned golden asteroid at level ${level}, total asteroids: ${asteroids.length}`); } else { - asteroids.push(new Asteroid()); + asteroids.push(new Asteroid(null, null, false)); // White asteroid + console.log(`Spawned white asteroid at level ${level}, total asteroids: ${asteroids.length}`); } } } @@ -55,14 +60,14 @@ function draw() { text("Score: " + score, 50, 60); text("Level: " + level, 50, 90); - // Handle continuous key input (WASD) - if (keyIsDown(65)) { // A key + // Handle continuous key input (WASD and Arrow Keys) + if (keyIsDown(65) || keyIsDown(LEFT_ARROW)) { // A or Left Arrow ship.setRotation(-0.1); } - if (keyIsDown(68)) { // D key + if (keyIsDown(68) || keyIsDown(RIGHT_ARROW)) { // D or Right Arrow ship.setRotation(0.1); } - if (keyIsDown(87)) { // W key + if (keyIsDown(87) || keyIsDown(UP_ARROW)) { // W or Up Arrow ship.boosting(true); } else { ship.boosting(false); @@ -232,7 +237,7 @@ function keyPressed() { } } if (keyCode === 82 && gameOver) { // R to restart - lives = 3; + lives = 100; score = 0; level = 1; initialObjects = 5; @@ -251,10 +256,10 @@ function keyPressed() { } function keyReleased() { - if (keyCode === 65 || keyCode === 68) { // A or D key + if (keyCode === 65 || keyCode === 68 || keyCode === LEFT_ARROW || keyCode === RIGHT_ARROW) { // A, D, Left, Right ship.setRotation(0); } - if (keyCode === 87) { // W key + if (keyCode === 87 || keyCode === UP_ARROW) { // W or Up Arrow ship.boosting(false); } } \ No newline at end of file