xxxxxxxxxx
28
let sounds = [];
let soundIndex = 0;
let img;
function preload() {
for (let i = 0; i < 12; i++) {
sounds.push(loadSound("cat_" + (i + 1) + ".mp3"));
}
img = loadImage("images.jpeg");
}
function setup() {
createCanvas(600, 400);
img.loadPixels();
image(img, 0, 0, width, height);
}
function mousePressed() {
if (!sounds[soundIndex].isPlaying()) {
sounds[soundIndex].play();
} else {
sounds[soundIndex].pause();
soundIndex++;
}
}