// CAKE MONSTER // Assignment 3 Program 2 KIB205 Laura Packer n6874606 class Cake { // X Position float xPos; // Y Position float yPos; // Speed of Cake float speed; // General size of Cake float r; // Cake Constructor Cake() { // General size of Cake r = 8; // Start at random X Position within window width xPos = random(wSize); // Start at random Y Position a bit above 0 yPos = random(0-r*3,0-r*4); // Random speed between 3 and 6 speed = random(3,6); } // Move method void move() { // Add speed to Y Position yPos += speed; } // Method to check if cake has reached bottom of screen boolean reachedBottom() { // Once cake passes beyond the screen... if (yPos > height + r*4) { return true; } else { return false; } } // Display Method void display() { // No Stroke noStroke(); // Draw Cake // Base of Cake // Fill with yellow fill(249,233,122); // Draw ellipse & rectangle ellipse(xPos,yPos,45,20); rectMode(CENTER); rect(xPos,yPos-10,45,20); // Icing // Change fill to pink fill(248,195,218); // Draw ellipse ellipse(xPos,yPos-20,45,20); // Draw candles // change fill to orange fill(246,140,31); // Draw sticks rect(xPos,yPos-30,2,18); rect(xPos-8,yPos-27,2,18); rect(xPos+8,yPos-27,2,18); // Draw flames // Change fill to yellow fill(249,233,122); ellipse(xPos,yPos-44,3,6); ellipse(xPos-8,yPos-41,3,6); ellipse(xPos+8,yPos-41,3,6); } // Ate Function // When cake is eaten void ate() { // Move cake offscreen xPos = - 200; } }