// Robert Chappel
// Dragons Egg
// Nicolas Hesler
//Interactive Toy
//Introduction to Media Computation
////Pseudo code
// click on element
// colour'd boxes at the bottom
// click on boxes to change colour of egg depending on box
// click on lower quarter of screen to change spots of the egg
//
//// Start egg colour
float eggR = 231;
float eggG = 76;
float eggB = 60;
/// spots starting colour
float spotR = 128;
float spotG = 0;
float spotB = 0;
void setup(){
size(400,400);
background(400,400);
fill(255);
}
void draw(){
frameRate(20);
rectMode(CORNERS);
ellipseMode(CENTER);
//room egg sits in
fill(136,146,158);
quad(1,399,120,300,280,300,399,399); //floor
quad(280,300,399,399,399,80,280,130); //right wall
quad(1,399,120,300,120,130,1,80); // leftwall
rect(120,300,280,130); // backwall
//roof
fill(102,51,0);
noStroke();
quad(1,80,120,130,280,130,399,80);
quad(1,1,1,80,400,80,400,1);
stroke(1);
strokeWeight(2);
line(1,10,400,10);
line(1,20,400,20);
line(1,30,400,30);
line(1,40,400,40);
line(1,50,400,50);
line(1,60,400,60);
line(1,70,400,70);
line(1,80,400,80);
line(23,90,377,90);
line(45,100,355,100);
line(68,110,330,110);
line(93,120,300,120);
//wall lines
line(120,130,1,82);
line(120,130,280,130);
line(280,130,400,81);
strokeWeight(1);
/// draw eggs and spots
drawEgg();
drawspots();
//// Buttons
greenButton();
whiteButton();
redButton();
blueButton();
blackButton();
}
////////////// egg drawing function ////////////////
void drawEgg(){
fill(eggR,eggG,eggB);
ellipse(200,280,100,150);
}
/////////////////////////functions////////////////////
/// change egg colour to blue
void drawblue(){
eggR =52;
eggG =152;
eggB =219;
}
/// change egg colour to red
void drawred(){
eggR =231;
eggG =76;
eggB =60;
}
/// change egg colour to white
void drawwhite(){
eggR =236;
eggG =240;
eggB =241;
}
// change egg colour to black
void drawblack(){
eggR =23;
eggG =32;
eggB =42;
}
/// change egg colour to green
void drawgreen(){
eggR =46;
eggG =204;
eggB =113;
}
/////////////////// Buttons /////////////////////////////////////
////////////// red button fucntion: changes egg to red
void redButton(){
fill(231,76,60);
rect(40,370,60,390);
}
////////// green button function: changes egg to green
void greenButton(){
fill(46,204,113);
rect(110,370,130,390);
}
/////////// white button function: changes egg to white
void whiteButton(){
fill(236,240,241);
rect(180,370,200,390);
}
////////// blue button function: changes egg too blue
void blueButton(){
fill(52,152,219);
rect(250,370,270,390);
}
/////////// black button function; changes egg to black
void blackButton(){
fill(23,32,42);
rect(320,370,340,390);
}
// draw spots on egg
void drawspots(){
fill(spotR, spotG, spotB);
ellipse(190,275,5,5);
ellipse(220,275,7,7);
ellipse(200,295,4,6);
ellipse(224,245,10,10);
ellipse(215,230,8,8);
ellipse(200,320,10,10);
ellipse(185,300,8,8);
ellipse(175,245,7,7);
ellipse(230,310,7,7);
stroke(1);
}
///////// Spots on egg colour randomizer //////
void spotColour(){
spotR = random(255);
spotG = random(255);
spotB = random(255);
}
/////////// player imput /////////// key press area
void mousePressed(){
//// clicking red square will change the spots and change egg to red
if( mouseX >= 40 && mouseX <= 60 && mouseY <= 390 && mouseY >= 370){
drawred();
}
////// clicking green square will change spots and change egg to green
if ( mouseX >= 110 && mouseX <=130 && mouseY <= 390 && mouseY >=370){
drawgreen();
}
/////// clicking white square will change spots and change egg to white
if ( mouseX >= 180 && mouseX <=200 && mouseY <= 390 && mouseY >=370){
drawwhite();
}
/////// clicking blue square will turn egg to blue and change spots
if ( mouseX >= 250 && mouseX <=270 && mouseY <= 390 && mouseY >=370){
drawblue();
}
//// clicking blue square will change spots and change egg to white
if (mouseX >= 320 && mouseX <=340 && mouseY <= 390 && mouseY >=370){
drawblack();
}
////// clicking lower area of the scene will change spots
if(mouseX >= 10 && mouseX <= 390 && mouseY <= 390 && mouseY >= 370){
spotColour();
}
}