xxxxxxxxxx
void setup(){
size(800,400);
background(100);
}
int x1=100;
int x2=80;
int x3=60;
int x4=40;
int x5=20;
void draw(){
strokeWeight(2);
background(100);
line(0,80,800,80);//horizon
rectMode(CENTER);
fill(0,80,100);
rect(400,40,800,80);
//line behind racers
line(118,80,20,380);
//finish
line(700,80,640,380);
line(0,0,0,400);//line on left
line(0,400,800,400); //bottom line
line(800,0, 800,800);
//lines between racers
line(100,140,800,140);
line(80,195,800,195);
line(60,255,800,255);
line(40,325,800,325);
line(20,380,800,380);
//animals
target(x1,100);
target(x2,160);
target(x3,220);
target(x4,285);
target(x5,350);
//adding random to each racer
float speed1=random((-1/2),(13/2));
float speed2=random((-1/2),7);
float speed3=random(-2,8);
float speed4=random((-5/2),9);
float speed5=random(-2,9);
x1=x1+speed1;
x2=x2+speed2;
x3=x3+speed3;
x4=x4+speed4;
x5=x5+speed5;
if (x1 > 765){
noLoop();
textSize(32);
text("RACER 1 WINS", 10, 30); ;
}
if (x2 > 765){
noLoop();
textSize(32);
text("RACER 2 WINS", 10, 30); ;
}
if (x3 > 765){
noLoop();
textSize(32);
text("RACER 3 WINS", 10, 30); ;
}
if (x4 > 765){
noLoop();
textSize(32);
text("RACER 4 WINS", 10, 30); ;
}
if (x5 > 765){
noLoop();
textSize(32);
text("RACER 5 WINS", 10, 30); ;
}
}
void target(int x, int y){
strokeWeight(1);
fill(#E3AEAE);
ellipse(x-10,y+8, 50,30); //body
fill(#E3AEAE);
ellipse(x+20,y-4, 10,15); //right ear
ellipse(x+12,y-4, 10,15); //left ear
fill(#E3AEAE);
ellipse(x+20,y+2, 30,20); //head
ellipse(x+20,y-2, 2,2); //eye
fill(#E3AEAE);
ellipse(x+34,y+1, 4,4); //nose
ellipse(x+10,y+20, 10,5); //rght foot front
ellipse(x+5,y+22, 10,5); //left foot front
ellipse(x-30,y+19, 10,5); //rght foot back
ellipse(x-28,y+21, 10,5); //left foot back
}