xxxxxxxxxx
85
let count;
let n;
let price;
let button;
let col;
function preload () {
bakery = loadImage("bakery.jpg");
cookie = loadImage("cookie.png")
}
function setup() {
createCanvas(1000, 1000);
count = 0;
n = 1;
price = 10;
}
function draw() {
background(220);
push();
translate(999.5, 999.5);
rotate(PI)
image(bakery, 0, 0, 1500, height);
pop();
image(cookie, 260, 340);
noStroke();
fill(0);
rect(0, 0, 200, 100)
fill(255);
textSize(20);
text("Cookies: " + count, 50, 50);
if (count >= price) {
fill(255);
} else {
fill(200);
}
ellipse(width / 10 * 9, height / 10, 50, 50);
if(mouseIsPressed && dist(mouseX, mouseY, width / 2, height / 2) <= width / 6) {
push();
translate(999.5, 999.5);
rotate(PI)
image(bakery, 0, 0, 1500, height);
pop();
noStroke();
fill(0);
rect(0, 0, 200, 100)
fill(255);
textSize(20);
text("Cookies: " + count, 50, 50);
if (count >= price) {
fill(255);
} else {
fill(200);
}
ellipse(width / 10 * 9, height / 10, 50, 50);
image(cookie, 287, 350, 425, 300);
}
}
function mousePressed() {
if (dist(mouseX, mouseY, width / 2, height / 2) <= width / 6) {
count += n;
}
if (dist(mouseX, mouseY, width / 10 * 9, height / 10) <= 250 && count >= price) {
//cursor
}
if (dist(mouseX, mouseY, width / 10 * 9, height / 10 *2) <= 250 && count >= price) {
//add cursor somehow
}
}