// CAKE MONSTER // Assignment 3 Program 2 KIB205 Laura Packer n6874606 // Monster Class class Monster { // Monster Diametre float diam; // Eye Colour color eCol; // X Position float xPos; // Y Position float yPos; // Monster Constructor // Set temp variables for radius and eye colour Monster(float tempDiam, color tempECol) { // Temp Radius diam = tempDiam; // Temp Eye Colour eCol = tempECol; } // Set location of Monster void setLocation(float tempX, float tempY) { // Temp X Position xPos = tempX; // Temp Y Position yPos = tempY; } // Display Method void display() { // GREEN MONSTER noStroke(); // Body // Set fill to green fill(106,189,69); // Draw ellipse ellipse(xPos,yPos,diam,diam); // Large circles for eyes // Set fill to white fill(255); // Draw ellipses ellipse(xPos-40,yPos+10,65,65); ellipse(xPos+40,yPos+10,65,65); // Small circles for eyes // Set fill to eCol variable fill(eCol); // Draw ellipses ellipse(xPos-33,yPos-8,15,15); ellipse(xPos+33,yPos-8,15,15); // Ellipse for mouth // Set fill to pink fill(239,89,87); // Draw ellipse ellipse(xPos,yPos-64,80,30); // Nose // Set fill to darker green fill(82,153,67); // Draw triangle beginShape(); vertex(xPos,yPos-30); vertex(xPos+6,yPos-20); vertex(xPos-6,yPos-20); endShape(); } // Boolean Intersect Function // With help from Example 10-3: Bouncing Ball with Intersection // http://www.learningprocessing.com/examples/chapter-10/example-10-3/ // Returns true if monster intersects a cake boolean intersect(Cake d) { // Calculate distance between current X,Y and d X,Y float distance = dist(xPos,yPos,d.xPos,d.yPos); // Check distance and return true or false if (distance < diam/2 + d.r) { return true; } else { return false; } } }