///////////////////////////////////////////////////////////////// //Author: Pamela Payad // //Ice Cream Scooper // //1. Click on the ice cream flavour you want. // //2. Click on the toppings you want. // //3. Click on the cone that is faced down to restart your cone.// ///////////////////////////////////////////////////////////////// //set variables int toppingsContainer=30; int iceCreamBucket=30; int iceCream=60; int iceCreamBucket2 = 30; float sprinklesR = random(200); float sprinklesG = random(200); float sprinklesB = random(200); //set up the window void setup() { size(400, 400); noStroke(); fill(100); //run background drawing function drawBackground(); } void draw() { //chocolate drawIceCreamCone(); drawIceCream(118, 80, 4, 45); //vanilla drawIceCream(250, 244, 232, 165); //strawberry drawIceCream(255, 216, 216, 285); //draw the cone drawIceCreamCone(); //draw the topping displays drawCherry(95, 60, 110, 60); drawCherry(115, 60, 130, 60); drawCherry(95, 80, 110, 80); drawCherry(115, 80, 130, 80); drawSprinkles(); drawWafer(); drawChocChips(); //update functions chooseFlavour(); chooseTopping(); restartCone(); } //draw the background with no updates void drawBackground() { noStroke(); //toppingsContainer counter// fill(220); rect(0, 0, 260, 240); fill(230); rect(10, 0, 260, 230); fill(190); rect(20, 20, 230, 200, 5); fill(203); rect(40, 130, 180, 80, 5); fill(234); rect(45, 130, 180, 80, 5); //make a loop for the background of each topping "container" for (toppingsContainer=30; toppingsContainer< 220; toppingsContainer=toppingsContainer+55) { fill(178); rect(toppingsContainer, 35, 40, 80, 5); } //ice cream counter// fill(200); rect(260, 0, 260, 400); fill(210); rect(270, 0, 270, 390); //make a loop for the background of each topping "bucket" for (iceCreamBucket=30; iceCreamBucket< 290; iceCreamBucket=iceCreamBucket+120) { fill(196); rect(285, iceCreamBucket, 100, 100, 5); } for (iceCreamBucket2=30; iceCreamBucket2< 290; iceCreamBucket2=iceCreamBucket2+120) { fill(196); rect(285, iceCreamBucket2, 100, 100, 5); } //table top// fill(100); rect(0, 240, 260, 180); fill(150); rect(10, 250, 240, 180, 5); fill(180); rect(15, 255, 235, 175, 5); //cones display fill(191, 161, 100); triangle(30, 400, 70, 400, 50, 340); fill(222, 187, 116); triangle(35, 400, 70, 400, 54, 350); noStroke(); fill(0, 101, 162); rect(230, 370, 15, 60); ellipse(237, 370, 35, 35); fill(0, 74, 118); ellipse(235, 370, 20, 27); } // draw regular ice cream cone without ice cream void drawIceCreamCone() { //ice cream cone// fill(191, 161, 100); triangle(60, 200, 140, 460, 200, 200); fill(222, 187, 116); triangle(70, 200, 150, 470, 200, 200); } //draw an ice cream scooper that follows that mouse void drawIceCreamScoop(int iceR, int iceG, int iceB) { noStroke(); fill(iceR, iceG, iceB); ellipse(132, 170, 140, 140); for (iceCream=60; iceCream< 240; iceCream=iceCream+140) { fill(iceR, iceG, iceB); ellipse(iceCream, 180, 40, 40); } //ice cream cone// fill(191, 161, 100); triangle(60, 200, 140, 460, 200, 200); fill(222, 187, 116); triangle(70, 200, 150, 470, 200, 200); } //makes the squares for the ice cream //parameters needed are the colour and y position void drawIceCream(int flavourR, int flavourG, int flavourB, int iceY) { noStroke(); fill(flavourR, flavourG, flavourB); rect(300, iceY, 75, 75, 5); } //draw the cherry display with the parameters of the positions of the cherries void drawCherry(int cherryX, int cherryY, int stemX, int stemY) { stroke(85, 0, 21); fill(185, 0, 15); ellipse(cherryX, cherryY, 12, 12); noFill(); arc(stemX, stemY, 30, 30, PI, PI+QUARTER_PI); } //draw the display for the wafer void drawWafer() { noStroke(); fill(216, 195, 109); rect(145, 50, 12, 40); fill(216, 195, 109); rect(160, 35, 12, 40); fill(255, 226, 147); rect(147, 50, 10, 40); fill(255, 226, 147); rect(162, 35, 10, 40); } //draw the diplay of the chocolate chips void drawChocChips() { stroke(96, 68, 0); fill(116, 83, 0); triangle(220, 65, 225, 60, 230, 65); triangle(210, 55, 215, 50, 220, 55); triangle(200, 45, 205, 40, 210, 45); triangle(220, 85, 225, 80, 230, 85); triangle(210, 75, 215, 70, 220, 75); triangle(200, 65, 205, 60, 210, 65); triangle(220, 105, 225, 100, 230, 105); triangle(210, 95, 215, 90, 220, 95); triangle(200, 85, 205, 80, 210, 85); } //draw the diplay of the chocolate sprinkles void drawSprinkles() { stroke(sprinklesR, sprinklesG, sprinklesB); line(40, 50, 50, 53); stroke(sprinklesR+90, sprinklesG-8, sprinklesB); line(60, 63, 65, 70); stroke(sprinklesR+23, sprinklesG-55, sprinklesB); line(30, 70, 40, 60); stroke(sprinklesR+3, sprinklesG+55, sprinklesB+90); line(40, 100, 30, 90); stroke(sprinklesR+32, sprinklesG+57, sprinklesB-90); line(45, 80, 35, 90); stroke(sprinklesR+50, sprinklesG+5, sprinklesB-26); line(55, 90, 60, 80); } //draw topping functions for when they are chosen// void sprinkles() { stroke(sprinklesR, sprinklesG, sprinklesB); line(100, 140, 110, 130); stroke(sprinklesR+100, sprinklesG-90, sprinklesB); line(120, 110, 130, 120); stroke(sprinklesR-100, sprinklesG-90, sprinklesB); line(150, 150, 160, 140); stroke(sprinklesR+10, sprinklesG-90, sprinklesB); line(140, 130, 150, 125); stroke(sprinklesR+130, sprinklesG+90, sprinklesB); line(110, 150, 120, 145); } void chocChips() { stroke(96, 68, 0); fill(116, 83, 0); triangle(115, 120, 120, 110, 130, 120); triangle(90, 140, 100, 130, 110, 140); triangle(160, 130, 170, 120, 175, 130); triangle(140, 140, 150, 130, 160, 140); triangle(135, 110, 140, 100, 145, 110); } void cherry() { noStroke(); fill(124, 1, 11); ellipse(130, 100, 30, 30); fill(185, 0, 15); ellipse(130, 100, 27, 27); stroke(85, 0, 21); noFill(); arc(160, 90, 60, 60, PI, PI+QUARTER_PI); } void wafer() { noStroke(); fill(216, 195, 109); quad(165, 75, 190, 100, 160, 150, 135, 135); fill(255, 226, 147); quad(170, 80, 190, 100, 160, 150, 140, 140); } //choose the topping here void chooseTopping() { noStroke(); if (mousePressed) { if (mouseX > 80 && mouseX < 130 && mouseY > 40 && mouseY < 120) { cherry(); } else if (mouseX > 130 && mouseX < 170 && mouseY > 40 && mouseY < 120) { wafer(); } else if (mouseX > 30 && mouseX < 170 && mouseY > 40 && mouseY < 120) { sprinkles(); } else if (mouseX > 180 && mouseX < 230 && mouseY > 40 && mouseY < 120) { chocChips(); } } } //detects when the chosen flavour is clicked void chooseFlavour() { noStroke(); if (mousePressed) { //detect when the mouse is over the ice cream and run the ice cream function and colours in the parameters specified in the parameters if (mouseX> 300 && mouseX < 380 && mouseY > 40 && mouseY < 120) { drawIceCreamScoop(118, 80, 4); } else if (mouseX> 300 && mouseX < 380 && mouseY > 140 && mouseY < 240) { drawIceCreamScoop(250, 244, 232); } else if (mouseX> 300 && mouseX < 380 && mouseY > 270 && mouseY <360) { drawIceCreamScoop(255, 216, 216); } } } //when user clicks on the cone, the background properties are redrawn void restartCone() { if (mousePressed) { //detect when the mouse is over the ice cream and run the ice cream function and colours in the parameters specified in the parameters if (mouseX> 40 && mouseX < 80 && mouseY > 340 && mouseY < 400) { drawBackground(); //run background drawing function drawBackground(); //chocolate drawIceCreamCone(); drawIceCream(118, 80, 4, 45); //vanilla drawIceCream(250, 244, 232, 165); //strawberry drawIceCream(255, 216, 216, 285); //draw the cone drawIceCreamCone(); //draw the topping displays drawCherry(95, 60, 110, 60); drawCherry(115, 60, 130, 60); drawCherry(95, 80, 110, 80); drawCherry(115, 80, 130, 80); drawSprinkles(); drawWafer(); drawChocChips(); } } }