xxxxxxxxxx
let yay;
let trombone;
function preload() {
yay = loadSound("yay.mp3");
trombone = loadSound("trombone.mp3");
}
function setup() {
createCanvas(500, 500);
}
function draw() {
background(230);
noStroke();
fill(0, 255, 0);
ellipse(150, 250, 80, 80);
fill(255, 0, 0);
ellipse(330, 250, 80, 80);
}
function mousePressed() {
let d = dist(mouseX, mouseY, 150, 250);
if (d < 40) {
console.log("click");
if (yay.isPlaying() == false) {
yay.play();
}
}
d = dist(mouseX, mouseY, 330, 250);
if (d < 40) {
console.log("click");
if (trombone.isPlaying() == false) {
trombone.play();
}
}
}