xxxxxxxxxx
//Virus ROBOT
//Dances if you've got music and hand-eye (ear?) coordination.
//Created 23 January 2016
//By Kendrick Hayman
//hayman.15@osu.edu
void setup()
{
size(500,500);
}
void draw()
{
int x = mouseX;
int y = mouseY;
background(200,220,250);
noFill();
strokeWeight(4);
curve(200,200,0,350,500,350,500,450); //Ground
beginShape(); //Right Front Leg
line(x,y+50,310,150);
endShape();
line(310,150,350,420);
beginShape(); //Left Front Leg
line(x,y+50,190,150);
endShape();
line(190,150,150,420);
beginShape(); // Left Middle Leg
line(x,y+50,150,200);
endShape();
line(150,200,120,410);
beginShape(); // Right Middle Leg
line(x,y+50,350,200);
endShape();
line(350,200,380,410);
beginShape(); // Left Back Leg
line(x,y+50,200,190);
endShape();
line(200,190,180,400);
beginShape(); // Right Back Leg
line(x,y+50,300,190);
endShape();
line(300,190,320,400);
stroke(255); // Body of Virus ROBOT
strokeWeight(1);
fill(230,75,50);
rectMode(CENTER);
rect(x,y,20,100);
stroke(0);
fill(0,0,40,150);
rect(x+5,y,10,100);
line(x-10,y,x+10,y);
line(x-10,y+5,x+10,y+5);
line(x-10,y+10,x+10,y+10);
fill(255); // Head of Virus ROBOT
triangle(x-2,y-36,x-34,y-55,x-20,y-55);
triangle(x,y-36,x+34,y-55,x+20,y-55);
triangle(x,y-36,x+20,y-55,x-20,y-55);
line(x,y-100,x+34,y-95);
line(x+20,y-55,x+34,y-95);
line(x,y-100,x-1,y-115);
fill(100,100,255,200);
triangle(x,y-100,x-36,y-95,x-20,y-55);
fill(75,75,100,200);
triangle(x-20,y-55,x-36,y-94,x-34,y-55);
noFill();
triangle(x,y-100,x+20,y-55,x-20,y-55);
fill(2,255,200,100);
polygon(x,y-75,40,6);
stroke(0);
fill(200);
if (mousePressed) {
fill(230,75,50);
createGraphics(x,y+60);
ellipse(x,y+50,1,1);
} else {
stroke(0);
}
}
void polygon(float x, float y, float radius, int npoints) {
float angle = TWO_PI / npoints;
beginShape();
for (float a = .5; a < TWO_PI; a += angle) {
float sx = x + cos(a) * radius;
float sy = y + sin(a) * radius;
vertex(sx, sy);
}
endShape(CLOSE);
}
//--------kept as failed attempt-----------//
//What went wrong?
//boolean OverBody = false;
//boolean shazam = false;
//void mousePressed() {
// if(OverBody) {
//shazam = true;
// } else {
// shazam = false;
// }
//}