xxxxxxxxxx
void setup()
{
background(0);
size(1000, 600);
}
float speed1 = random(1,10);
float speed2 = random(1,10);
float speed3 = random(1,10);
float x_1 = 0;
float x_2 = 0;
float x_3 = 0;
void draw()
{
background(0);
fill(255,0,0);
racerball(x_1, 100);
x_1 = x_1 + speed1;
fill(0,255,0);
racerball(x_2, 300);
x_2 = x_2 + speed2;
fill(0,0,255);
racerball(x_3, 500 );
x_3 = x_3 + speed3;
if(x_1>1000)
{
noLoop();
fill(255);
textMode(CENTER);
text("RED WINS", width/2,height/2);
}
if(x_2>1000)
{
noLoop();
fill(255);
textMode(CENTER);
text("GREEN WINS", width/2,height/2);
}
if(x_3>1000)
{
noLoop();
fill(255);
textMode(CENTER);
text("BLUE WINS", width/2,height/2);
}
}
void racerball(float x,float y)
{
ellipse(x,y,50,50);
}