class Pizza { constructor(pos, r) { if (pos) { this.pos = pos.copy(); this.r = r ? r / 2 : random(40, 60); } else { this.pos = createVector(random(width), random(height)); this.r = random(40, 60); while (dist(this.pos.x, this.pos.y, ship.pos.x, ship.pos.y) < 100) { this.pos = createVector(random(width), random(height)); } } this.vel = p5.Vector.random2D(); this.vel.mult(random(1, 3)); this.total = floor(random(8, 12)); // For potential future use this.offset = []; for (let i = 0; i < this.total; i++) { this.offset[i] = random(-this.r * 0.3, this.r * 0.3); } } update() { this.pos.add(this.vel); } edges() { if (this.pos.x > width + this.r) this.pos.x = -this.r; else if (this.pos.x < -this.r) this.pos.x = width + this.r; if (this.pos.y > height + this.r) this.pos.y = -this.r; else if (this.pos.y < -this.r) this.pos.y = height + this.r; } hits(bullet) { let d = dist(this.pos.x, this.pos.y, bullet.pos.x, bullet.pos.y); return d < this.r; } breakup() { let newHamburgers = []; if (this.r > 20) { newHamburgers.push(new Hamburger(this.pos, this.r)); newHamburgers.push(new Hamburger(this.pos, this.r)); } return newHamburgers; } show() { push(); translate(this.pos.x, this.pos.y); // Rotate to align with velocity let angle = atan2(this.vel.y, this.vel.x); rotate(angle); // Draw pizza image (20 points) if (pizzaImg) { imageMode(CENTER); let scaleFactor = (this.r * 2) / pizzaImg.width; // Scale to match radius scale(scaleFactor); image(pizzaImg, 0, 0); } else { // Fallback if image fails to load fill(255, 100, 100); // Brighter red for pizza stroke(255); ellipse(0, 0, this.r * 2); console.log('Pizza image not loaded, using fallback'); } pop(); } }