xxxxxxxxxx
28
let sounds = [];
let timer = 1000;
let images = [];
function preload() {
for (let i = 0; i < 6; i = i + 1) {
sounds[i] = loadSound("sounds/" + i + ".mp3");
images[i] = loadImage("images/" + i + ".png");
}
}
function setup() {
createCanvas(600, 400);
background(165, 188, 204);
}
function draw() {
soundNumber = floor(random(0, sounds.length));
imgNumber = floor(random(0, images.length));
if (millis() > timer) {
sounds[soundNumber].play();
timer = timer + round(random(2000, 8000));
//print("i played a sound");
image(images[imgNumber], 0, 0, 600, 400);
}
}