/* SMOOTHIEEEEEESSSSSS */
//~~~~Sanaa Memon~~~~~~//
// ~~21/10/16~~
// ~~PROG 14998~~
//Controls: Click the buttons on the blender//
//to make a different coloured smoothie//
/*---------------------*/
//Declare variables to change the colour of the smoothie
float smoothieR = 255;
float smoothieG = 255;
float smoothieB = 255;
//Variable for the number of berries created
int b = 0;
//Array of berries that appear when the blender is on
Berry[] berries = new Berry[30];
//Blender and smoothie objects
Blender blendy;
Smoothie smootheroni;
Glass glass;
CounterTop countertop;
Kitchen kitchen;
void setup() {
size(800, 600);
//Initialize objects
blendy = new Blender();
smootheroni = new Smoothie();
glass = new Glass();
countertop = new CounterTop();
kitchen = new Kitchen();
//Creates multiple berries equal to the length of the array
for (int b = 0; b < berries.length; b++) {
berries[b] = new Berry();
}
}
void draw() {
//Draw objects from back to front so they layer, Kitchen farthest back, Blender and Glass at the front so they appear above
kitchen.drawKitchen();
countertop.counterTop();
blendy.blenderer();
smootheroni.smoothies();
smootheroni.fillGlass();
glass.glass();
//Each of the 3 buttons creates a different coloured smoothie. The code within (mousePressed) sets constraints so a certain colour of smoothie only appears when the corresponding button is pressed
//Holding down the button creates random berries within the blender to create the illusion of movement
if (mousePressed) {
noStroke();
if (mouseX<370 & mouseX>350 & mouseY>440 & mouseY<450) {
smootheroni.smoothieUpdate1();
berries[b].drawBerry();
berries[b].berryX = random(340, 460);
berries[b].berryY = random(240, 390);
}
if (mouseX<410 & mouseX>390 & mouseY>440 & mouseY<450) {
smootheroni.smoothieUpdate2();
berries[b].drawBerry();
berries[b].berryX = random(340, 460);
berries[b].berryY = random(240, 390);
}
if (mouseX<450 & mouseX>430 & mouseY>440 & mouseY<450) {
smootheroni.smoothieUpdate3();
berries[b].drawBerry();
berries[b].berryX = random(340, 460);
berries[b].berryY = random(240, 390);
}
}
}class Berry {
//Variables for the position of the berries
float berryX = random(340, 460);
float berryY = random(240, 390);
//Variables to store berry colour
float berryRed = 255;
float berryGreen = 255;
float berryBlue = 255;
//Function that draws berries
void drawBerry() {
fill(berryRed, berryGreen, berryBlue);
ellipse(berryX, berryY, 15, 15);
}
}class Blender {
//Draw all shapes that make up the blender
void blenderer() {
noStroke();
rectMode(CORNERS);
//lid
fill(25);
rect(300, 120, 500, 140, 10);
rect(360, 110, 440, 130, 10);
fill(120);
//body
rect(310, 150, 490, 305, 4);
quad(310, 300, 490, 300, 480, 350, 320, 350);
quad(320, 350, 480, 350, 450, 410, 350, 410);
//inner wall
fill(220);
rect(315, 150, 485, 305, 4);
quad(315, 300, 485, 300, 475, 350, 325, 350);
quad(325, 350, 475, 350, 445, 405, 355, 405);
//handle
fill(120);
quad(480, 330, 520, 300, 540, 300, 480, 350);
quad(490, 160, 530, 170, 530, 190, 490, 180);
rect(520, 170, 540, 300, 0, 12, 2, 0);
//base
fill(80);
quad(340, 420, 460, 420, 500, 520, 300, 520);
fill(50);
rect(300, 520, 500, 550);
//buttons
fill(200);
stroke(150);
strokeWeight(10);
ellipse(400, 500, 60, 60);
//button 1
stroke(200, 0, 0);
fill(200, 0, 0);
rect(350, 440, 370, 450, 2);
//button 2
stroke(0, 200, 0);
fill(0, 200, 0);
rect(390, 440, 410, 450, 2);
//button 3
stroke(50, 0, 200);
fill(50, 0, 200);
rect(430, 440, 450, 450, 2);
}
}class CounterTop {
void counterTop() {
noStroke();
rectMode(CORNERS);
fill(100, 55, 30);
rect(0, 470, 800, 600);
}
}class Glass {
//Store X and Y values of coordinates to draw the Glass
PVector glassX;
PVector glassY;
//Glass X and Y coords
Glass() {
glassX = new PVector(170, 240);
glassY = new PVector(450, 550);
}
void glass() {
noFill();
stroke(255);
strokeWeight(2);
quad(glassX.x, glassY.x, glassX.y, glassY.x, glassX.y-10, glassY.y, glassX.x+10, glassY.y);
}
}//A static background of shapes that move based on your mouse movement but cannot be interacted with
class Kitchen {
//One function to draw the entire background :)
void drawKitchen() {
rectMode(CORNERS);
background(0);
noStroke();
fill(#FCE0B4);
rect(0, 0, 800, 100);
fill(#EDD3A9);
rect(0, 100, 800, 200);
fill(#E0C8A0);
rect(0, 200, 800, 300);
fill(#D1BA95);
rect(0, 300, 800, 400);
fill(#C4AF8C);
rect(0, 400, 800, 500);
noStroke();
//first
fill(#4C7093);
rect(60-mouseX/50, 320-mouseY/65, 260-mouseX/50, 490-mouseY/65);
fill(255);
rect(60-mouseX/50, 300-mouseY/65, 260-mouseX/50, 315-mouseY/65);
fill(#A9C0E0);
rect(70-mouseX/50, 330-mouseY/65, 155-mouseX/50, 480-mouseY/65);
rect(165-mouseX/50, 330-mouseY/65, 250-mouseX/50, 480-mouseY/65);
fill(#4C7093);
//second
rect(270-mouseX/50, 300-mouseY/65, 425-mouseX/50, 315-mouseY/65);
rect(270-mouseX/50, 300-mouseY/65, 285-mouseX/50, 490-mouseY/65);
rect(410-mouseX/50, 300-mouseY/65, 425-mouseX/50, 490-mouseY/65);
fill(#A9C0E0);
rect(290-mouseX/50, 320-mouseY/65, 405-mouseX/50, 350-mouseY/65);
rect(290-mouseX/50, 360-mouseY/65, 405-mouseX/50, 475-mouseY/65);
//oven
rect(430-mouseX/50, 300-mouseY/65, 585-mouseX/50, 335-mouseY/65);
fill(#4C7093);
rect(430-mouseX/50, 340-mouseY/65, 585-mouseX/50, 450-mouseY/65);
rect(430-mouseX/50, 450-mouseY/65, 585-mouseX/50, 490-mouseY/65);
fill(220);
rect(450-mouseX/50, 370-mouseY/65, 570-mouseX/50, 430-mouseY/65, 6);
//last
fill(255);
rect(590-mouseX/50, 300-mouseY/65, 800-mouseX/50, 315-mouseY/65);
fill(#4C7093);
rect(590-mouseX/50, 320-mouseY/65, 800-mouseX/50, 490-mouseY/65);
fill(255);
rect(275-mouseX/50, 290-mouseY/65, 420-mouseX/50, 300-mouseY/65);
//upper layer
fill(#4C7093);
rect(60-mouseX/50, 40-mouseY/65, 260-mouseX/50, 190-mouseY/65);
fill(255);
rect(70-mouseX/50, 50-mouseY/65, 155-mouseX/50, 180-mouseY/65);
rect(165-mouseX/50, 50-mouseY/65, 250-mouseX/50, 180-mouseY/65);
//window
rect(270-mouseX/50, 30-mouseY/65, 420-mouseX/50, 260-mouseY/65);
fill(25, 150, 250);
rect(280-mouseX/50, 40-mouseY/65, 340-mouseX/50, 100-mouseY/65);
rect(350-mouseX/50, 40-mouseY/65, 410-mouseX/50, 100-mouseY/65);
rect(280-mouseX/50, 110-mouseY/65, 410-mouseX/50, 240-mouseY/65);
//hutch
fill(100);
rect(485-mouseX/50, 30-mouseY/65, 535-mouseX/50, 50-mouseY/65);
fill(50);
rect(490-mouseX/50, 55-mouseY/65, 530-mouseX/50, 90-mouseY/65);
triangle(510-mouseX/50, 80-mouseY/65, 575-mouseX/50, 105-mouseY/65, 450-mouseX/50, 105-mouseY/65);
fill(100);
rect(430-mouseX/50, 110-mouseY/65, 590-mouseX/50, 120-mouseY/65);
//far right
fill(#4C7093);
rect(600-mouseX/50, 30-mouseY/65, 800-mouseX/50, 190-mouseY/65);
fill(200);
rect(610-mouseX/50, 40-mouseY/65, 695-mouseX/50, 80-mouseY/65);
rect(610-mouseX/50, 90-mouseY/65, 695-mouseX/50, 125-mouseY/65);
rect(610-mouseX/50, 135-mouseY/65, 695-mouseX/50, 180-mouseY/65);
rect(705-mouseX/50, 40-mouseY/65, 790-mouseX/50, 180-mouseY/65);
//left wall
fill(250);
rect(0, 0, 20-mouseX/50, 500-mouseY/65);
//repeating pattern
float rectX = 450;
float rectY = 145;
//To avoid redrawing the same shape 5 times
while (rectX<590) {
fill(200, 0, 0);
rectMode(CENTER);
rect(rectX-mouseX/50, rectY-mouseY/65, 25, 25);
rectX+=30;
rectY+=30;
}
}
}class Smoothie {
//Draws the starting state of the smoothie, white
void smoothies() {
noStroke();
fill(smoothieR, smoothieG, smoothieB);
rect(315, 230, 485, 305, 4);
quad(315, 300, 485, 300, 475, 350, 325, 350);
quad(325, 350, 475, 350, 445, 405, 355, 405);
}
//First colour change, pink
void smoothieUpdate1() {
smoothieR = 250;
smoothieG = 140;
smoothieB = 210;
fill(smoothieR, smoothieG, smoothieB);
rect(315, 210, 485, 305, 4);
quad(315, 300, 485, 300, 475, 350, 325, 350);
quad(325, 350, 475, 350, 445, 405, 355, 405);
}
//Second colour change, light green
void smoothieUpdate2() {
smoothieR = 210;
smoothieG = 250;
smoothieB = 170;
fill(smoothieR, smoothieG, smoothieB);
rect(315, 210, 485, 305, 4);
quad(315, 300, 485, 300, 475, 350, 325, 350);
quad(325, 350, 475, 350, 445, 405, 355, 405);
}
//Third colour change, purple
void smoothieUpdate3() {
smoothieR = 135;
smoothieG = 95;
smoothieB = 250;
fill(smoothieR, smoothieG, smoothieB);
rect(315, 210, 485, 305, 4);
quad(315, 300, 485, 300, 475, 350, 325, 350);
quad(325, 350, 475, 350, 445, 405, 355, 405);
}
//Fills the glass with the same colour of smoothie that is in the blender
void fillGlass() {
fill(smoothieR, smoothieG, smoothieB);
noStroke();
quad(170, 460, 240, 460, 230, 550, 180, 550);
}
}