xxxxxxxxxx
31
let drums = [];
let x, y
function preLoad() {
for (let d = 0; d < 7; d++) {
drums[d] = loadSound("drums/" + d + ".mp3");
drums.push(drum);
}
}
function setup() {
createCanvas(400, 400);
// console.log(drums)
}
function draw() {
x++
background(220);
x=0;
if (frameCount % 60 == 0) {
drums[0].play();
rect(x, y, 5, 15);
}
}
// function keyPressed() {
// drums[key].play();
// }
function keyPressed() {
drums[key - 1].play();
}