Now with cool theme
This commit is contained in:
20
sketch.js
20
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;
|
||||
|
Reference in New Issue
Block a user