xxxxxxxxxx
/*
Race Homework
Created 2/14/17
Tamara Sabbagh
tamara.sabbagh@gmail.com
*/
void setup(){
size(400, 400);
frameRate(30);
}
float xpos= int(random(width));
float xpos2= int(random(width));
float xpos3= int(random(width));
float xpos4= int(random(width));
void draw(){
background(#CCFFE5);
shape(xpos, 50, 50);
shape(xpos2, 150, 50);
shape(xpos3, 250, 50);
shape(xpos4, 350, 50);
xpos = xpos + int(random(1, 15));
if (xpos > 400){
noLoop();
println("Win");
fill(0);
text("Player 1 Wins!", width/2, height/2);
xpos=0;
}
xpos2 = xpos2 + int(random(1, 15));
if (xpos2 > 400){
noLoop();
println("Win");
fill(0);
text("Player 2 Wins!", width/2, height/2);
xpos2=0;
}
xpos3 = xpos3 + int(random(1, 15));
if (xpos3 > 400){
noLoop();
println("Win");
fill(0);
text("Player 3 Wins!", width/2, height/2);
xpos3=0;
}
xpos4 = xpos4 + int(random(1, 15));
if (xpos4 > 400){
noLoop();
println("Win");
fill(0);
text("Player 4 Wins!", width/2, height/2);
xpos4=0;
}
}
/*void keyPressed(){
final int k = key;
if (k==' ')
if (looping) noLoop();
else loop();
//pause with most recent key hit/any key
*/
void keyPressed(){
noLoop();
}
void keyReleased(){
loop();
}
void shape(float x, float y, int size){
fill(#CCE5FF);
ellipse(x, y, size, size);
}