xxxxxxxxxx
91
var x, y;
var strawx = -200;
var strawy = -200;
function setup() {
createCanvas(400, 400);
x = -200;
y = -200;
fill(236, 220, 194); //cup
rect(200 - 55, 70, 110, 230);
fill(236, 220, 194); //top
ellipse(200, 70, 110, 20);
ellipse(200, 300, 110, 20); //bottom
fill(199, 107, 15); //drink
rect(200 - 55, 95, 110, 200);
ellipse(200, 95, 110, 20);
noStroke();
ellipse(200, 296, 109, 20);
}
function draw() {
fill(0);
stroke(0);
textSize(19);
textAlign(CENTER);
text("Press b and click for boba", 200, 330);
text("Press j and click for jelly", 200, 350);
text("Press s for straw", 200, 370);
text("Press r to reset", 200, 390);
}
function mouseClicked() {
x = mouseX;
y = mouseY;
if (key === "j") {
//jelly
noStroke();
fill(216, 194, 192);
rect(x - 4, y - 2, 20, 10);
}
if (key === "b") {
//boba
stroke(0);
fill(54, 18, 18);
ellipse(x, y, 20, 20);
}
}
function keyPressed() {
if (key === "s") {
strawx = 200;
strawy = 200;
stroke(0);
fill(240, 222, 182);
rect(200 - 7.5, 25, 15, 260);
ellipse(200, 25, 15, 7);
noStroke();
ellipse(200, 25, 13.8, 7);
}
}
function keyPressed() {
if (key === "r") {
createCanvas(400, 400);
x = -200;
y = -200;
fill(236, 220, 194); //cup
rect(200 - 55, 70, 110, 230);
fill(236, 220, 194); //top
ellipse(200, 70, 110, 20);
ellipse(200, 300, 110, 20); //bottom
fill(199, 107, 15); //drink
rect(200 - 55, 95, 110, 200);
ellipse(200, 95, 110, 20);
noStroke();
ellipse(200, 296, 109, 20);
}
if (key === "s") {
strawx = 200;
strawy = 200;
stroke(0);
fill(240, 222, 182);
rect(200 - 7.5, 25, 15, 260);
ellipse(200, 25, 15, 7);
noStroke();
ellipse(200, 25, 13.8, 7);
}
}
//made by kathleen 2021