xxxxxxxxxx
27
let radius;
let x;
let y;
score = 0
function setup() {
createCanvas(400, 400);
frameRate (1);
}
function draw() {
background(220);
text("Score:" + score, 10, 25);
radius = 50
x = random (400);
y= random (400);
fill(random(255), random (255), random(255));
ellipse(x, y, radius*2, radius*2);
}
function mousePressed() {
let d = dist(mouseX, mouseY, x, y);
if (d<radius) {
fill('black')
score = score + 1
textSize(24);
fill('black');
text("Score:" + score, 10, 25);
}
}