xxxxxxxxxx
48
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];
var sounds = [];
function preload() {
soundFormats('mp3');
sounds[0] = loadSound('RollingSuitcase.mp3');
sounds[1] = loadSound('Airportambiance.mp3');
sounds[2] = loadSound('SeatbeltSound.mp3');
sounds[3] = loadSound('SeatbeltClick.mp3');
sounds[4] = loadSound('AirplaneTakeOff.mp3');
sounds[5] = loadSound('Eating.mp3');
sounds[6] = loadSound('Water.mp3');
sounds[7] = loadSound('AirplaneToilet.mp3');
sounds[8] = loadSound('AirplaneLanding.mp3');
}
function setup() {
createCanvas(500, 500);
colorMode(HSB);
}
function draw() {
background(0);
strokeWeight(1);
stroke(255);
i = 0;
for (var x = 50; x < width; x = x + 180)
for (var y = 50; y < 500; y = y + 180) {
ellipse(x, y, 25, 25);
text(numbers[i], x, y);
i++;
}
}
function mousePressed() {
// Check if mouse is inside the circle
var i = 0;
for (var x = 50; x < width; x = x + 180)
for (var y = 50; y < 500; y = y + 180) {
let d = dist(mouseX, mouseY, x, y);
if(d < 10){
sounds[i].play();
}
i++;
}
}