/* Robot Interactive Design Author: Jonathon Klassen Date: September 18, 2015 */ int blink=0; //blinking randomizer int r=0; //redness value int w=200; //robot's main colour float aY=170; //antenna Y coordinate boolean deploy=false; //whether antenna is deployed boolean heatUp=false; //whether robot is heating up void setup() { size(500, 500); frameRate(10); rectMode(CENTER); } void draw() { drawBackground(); //function which draws background stroke(r, r/2, 0); drawBody(); //function which draws the body blinking(); //function which handles blinking mouth(); //function which handles opening/closing mouth antenna(); //function which handles the antenna overheat(); //function which handles the overheating aesthetic openClose(); //function which handles opening/closing the body door } void drawBackground() { background(120); //background fill(80); stroke(0); rect(250, 460, 500, 100); //draw the ground for (int i=1; i<8; i++) { ellipse(70*i-25, 370, 20, 20); //draw background bolts } } void drawBody() { fill(w); //robot colour strokeWeight(6); rect(175, 360, 25, 90, 20); //draw arms rect(275, 360, 25, 90, 20); for (int i=0; i<3; i++) { //repeats the lines along the arms line(162.5, 330+i*20, 287, 330+i*20); //lines on arms } ellipse(175, 405, 30, 30); //draw hands ellipse(275, 405, 30, 30); rect(225, 380, 90, 170, 10); //draw body rect(225, aY, 10, 100); //draw antenna fill(0, 131, 180); ellipse(225, aY-35, 30, 10); fill(w); rect(225, 200, 200, 200, 50); //draw head rect(225, 380, 60, 80, 10); //draw body door ellipse(180, 450, 50, 50); //draw feet ellipse(270, 450, 50, 50); strokeWeight(4); fill(w-140); ellipse(205, 380, 10, 10); //draw door knob for (int i=0; i<5; i++) { //for loop which draws the eyes/ gradient stroke(r, 0, 0, 255-i*50); fill(255); ellipse(150, 200, 100-i*8, 100-i*8); //draw eyes ellipse(300, 200, 100-i*8, 100-i*8); textSize(20); fill(w-90); text("ARCHOS", 185, 140); //add name text } fill(w); } void blinking() { if (blink == 0) { //if the blink randomizer is 0 ellipse (150, 200, 100, 100); //draw closed eyes over the eyes ellipse (300, 200, 100, 100); line (100, 200, 200, 200); line (250, 200, 350, 200); blink =int(random(0, 20)); //after which randomize the blink variable } else { blink = int(random(0, 20)); //if inequal to 0, keep randomizing the blink } } void mouth() { stroke(r, r/2, 0); //if the mouth is clicked if (mousePressed && mouseX >=200 && mouseX <=250 && mouseY >=260 && mouseY <=280) { fill(0); rect(225, 270, 45, 15); //draw the mouth open textSize(20); fill(5, 134, 10); text("Feed me Seymour!", 310, 400); //print referential text } else { line(202.5, 270, 247.5, 270); //draw the mouth closed } //if the body door is clicked if (mousePressed && mouseX >=195 && mouseX <= 255 && mouseY >=340 && mouseY <=420) { line(202.5, 270, 182.5, 260); //draw the mouth smiling line(247.5, 270, 267.5, 260); } } void antenna() { fill(0, 131, 180); ellipse(210, 320, 10, 10); //draw antenna button //if the antenna button is clicked if (mousePressed && mouseX >=200 && mouseX <=220 && mouseY >=310 && mouseY <=330) { deploy = !deploy; //deploy or retract antenna } //if the antenna should deploy and isn't at max. length if (deploy == true && aY >=100) { aY-=3; //extend the antenna //if the antenna should retract and isn't at min. length } else if (deploy == false && aY <=170) { aY+=3; //retract the antenna } //if the antenna is fully deployed if (aY <=100) { //for loop which draws antenna waves for (int i=0; i<10; i++) { noFill(); stroke(0, 131, 180, 150-i*30); ellipse(225, aY-35, 30+i*20, 10+i*20); //draw antenna waves textSize(20); fill(4, 95, 196); text("I wonder how", 10, 60); //print text text("much bandwith", 10, 80); text("I get...", 10, 100); stroke(r, r/2, 0); } } } void overheat() { constrain(r, 0, 260); //ensure redness remains within 0 and 260 constrain(w, 200, 252); //ensure robot colour remains within 200 and 252 fill(255, 163, 13); ellipse(240, 320, 10, 10); //draw overheat button //if the overheat button is pressed if (mousePressed && mouseX >=230 && mouseX <=250 && mouseY >=310 && mouseY <=330) { heatUp = !heatUp; //overheat or cool robot } if (w >=252) { //if the robot is hot textSize(30); text("Hot! Hot! Hot!", 290, 70); //print text } //if the robot should overheat if (heatUp == true && r<260 && w<252) { //change colours to overheated ones r+=10; w+=2; } //if the robot should cool down if (heatUp == false && r>0 & w>200) { //restore default colours r-=10; w-=2; } } void openClose() { //if the body door is clicked if (mousePressed && mouseX >=195 && mouseX <= 255 && mouseY >=340 && mouseY <=420) { fill(w-100); rect(225, 380, 60, 80, 10); //draw body cavity space fill(w); ellipse(260, 380, 10, 10); //draw body door knob open rect(255, 380, 10, 80, 10); //draw body door open textSize(20); fill(193, 8, 8); //print ominous text text("That's not where I hid the bodies, tee hee.", 40, 30); } }