xxxxxxxxxx
65
let PinkX = 47;
let BlueX = 47;
let PeachX = 47;
function setup() {
createCanvas(700, 400);
textAlign(CENTER);
}
function draw() {
background(169, 222, 249);
noStroke();
fill(252, 246, 189);
rect(0, 0, 100, 400);
fill(228, 193, 249);
rect(600, 0, 100, 400);
fill(255, 153, 200);
circle(PinkX, 190, 70);
fill(200, 130, 350);
circle(BlueX, 70, 70);
fill(250, 183, 140);
circle(PeachX, 320, 70);
if (PinkX > 600 - 30) {
stroke(255);
fill(255);
textSize(30);
text("Pink wins!", width / 2, 200);
noLoop();
}
if (BlueX > 600 - 30) {
stroke(200);
fill(200);
textSize(30);
text("Blue wins!", width / 2, 200);
noLoop();
}
if (PeachX > 600 - 30) {
stroke(235);
fill(235);
textSize(30);
text("Peach wins!", width / 2, 200);
noLoop();
}
}
function keyPressed() {
if (key === "a" || key === "A") {
PinkX = PinkX + random(5, 20);
}
if (key === "h" || key === "H") {
BlueX = BlueX + random(5, 20);
}
if (key === "p" || key === "P") {
PeachX = PeachX + random(5, 20);
}
}