xxxxxxxxxx
/* Katie Frank
Art 3001
Racing bunnies
Feb 14, 2017
*/
void setup () {
size (500, 500);
background (155);
frameRate(30);
}
int x = 25; // center of bunnies
int y = 25;
float a = 25; //speed of bunnies
float b = 25;
float c = 25;
// float d = 25;
void draw() {
background(155);
line(465, 15, 465, 465); //finish line
line(25, 25, 500, 25); //horizontal line 1
line(25, 140, 500, 140); //horizontal line 2
line(25, 270, 500, 270); //horizontal line 3
line(25, 410, 500, 410); //horizontal line 4
bunny(a, 75);
a = a + random(0,10);
bunny(b, 215);
b = b + random(0,10);
bunny(c, 335);
c = c + random(0,10);
if (a > 465){
noLoop();
fill(255);
textSize(20);
textMode(CENTER);
text("BUNNY 1 WINS!", width/2,height/2);
}
if (b > 465){
noLoop();
textSize(20);
fill(255);
textMode(CENTER);
text("BUNNY 2 WINS!", width/2,height/2);
}
if (c > 465){
noLoop();
textSize(20);
fill(255);
textMode(CENTER);
text("BUNNY 3 WINS!", width/2,height/2);
}
}
void keyPressed(){
noLoop();
}
void keyReleased(){
loop();
}
void bunny(float x, float y) {
fill(255);
ellipse(x-55, y+5, 20, 20);//tail
fill(155);
ellipse(x-20, y+20, 80, 40); //body
fill(155);
ellipse(x-5, y-30, 10, 30); //left ear
ellipse(x+5, y-30, 10, 30); //right ear
fill (155);
ellipse(x, y, 40, 40); //head
fill(0);
ellipse(x, y+8, 10, 3); //mouth
fill(255);
rectMode(CENTER);
rect(x, y+13, 8, 8); //teeth
fill(255);
ellipse(x-5, y-8, 12, 20); //white left eye
fill (0);
ellipse (x-5, y-5, 5, 5); //blakc left eye
fill(255);
ellipse(x+5, y-8, 12, 20); //white right eye
fill (0);
ellipse (x+5, y-5, 5, 5); //black right eye
stroke(0);
fill(255, 100, 100);
ellipse(x, y, 10, 10); //nose
fill(155);
ellipse(x-50, y+35, 30, 15); //back feet
ellipse(x+15, y+35, 30, 15); //front feet
}