/*Lea Waller
Introduction to Media Computation
*/
///////VARIABLES///////
//Background Colour Change
boolean button = false;
int r = 73;
int g = 290;
int b = 100;
int a = 100;
//Bouncing
float x = 300;
float y = 10;
float speed = 2;
float gravity = 0.5;
//Bouncing Tofu Eyes
float w = 35;
float h = 1;
float eyeSize = 5;
//Background Color switches when mouse pressed
int backgroundColor = 100;
void setup() {
size(400,400);
frameRate(45);
}
void draw() {
strokeWeight(2);
if (button) {
background(254,186,187);
stroke(0);
} else {
background(187,167,219);
stroke(0);
}
///////BIG TOFU///////
//Table Big Tofu is sitting on
fill(206 ,247 ,242);
quad(0,320,220,320,140,400,0,400);
fill(167 ,219 ,213);
quad(140,400,140,400, 220,320,220,400);
//Body
fill(255);
rectMode(CENTER);
rect(r,g,b,a);
fill(190);
quad(23,240,40,230,140,230,123,240);
fill(100);
quad(123,240,140,230,140,330,123,340);
//Eyes
fill(255);
ellipse(85, 282, 20, 35);//Left Eye Whites
ellipse(60, 282, 20, 35);//Right Eye Whites
//Pupils
fill(5, 28, 5);
ellipse(58 + mouseX/60, 275 + mouseY/30, 16, 27); //Left Pupil
ellipse(83 + mouseX/60, 275 + mouseY/30, 16, 27); //Right Pupil
//Mouth
noFill();
arc(73,310,20,10,0,PI);
//When mouse pressed on Big Tofu body the background color changes
for (int x = backgroundColor; x <= width - backgroundColor; x += backgroundColor) {
}
//Bouncing Tofu
//Body
fill(255);
stroke(0);
rectMode(CENTER);
rect(x, y, 50, 50);
//Eyes
fill(0);
ellipse(x-w/3+1, y-h/2, eyeSize, eyeSize);
ellipse(x+w/3-1, y-h/2, eyeSize, eyeSize);
//Mouth
noFill();
arc(x,y,10,10,0,PI);
//Background interactive stars
colorMode(RGB);
stroke(255,255,255,mouseY/2);
strokeWeight(5);
point(35, 80);
point(55, 150);
point(60, 50);
point(110, 170);
point(150, 20);
point(20,30);
point(110,100);
point(230,200);
point(20,200);
point(175, 70);
point(230, 40);
point(280, 120);
point(290, 30);
point(320, 50);
point(370, 100);
point(380, 140);
point(190, 270);
point(35, 280);
point(155, 150);
point(350,360);
point(110, 170);
point(120, 150);
point(150, 20);
point(230, 340);
point(280, 120);
point(290, 135);
point(320, 250);
point(352, 165);
// Adding speed to Bouncing Tofus
y = y + speed;
speed = speed + gravity;
if (y > height) {
speed = speed * -0.97;
y = height;
}
}
//mousePressed for Big Tofu interaction w/ background color change
void mousePressed(){
if (mouseX > r && mouseX < r+b && mouseY > g && mouseY < g+a) {
button = !button;
}
}