xxxxxxxxxx
let shape;
let mySound1;
let mySound2;
function preload() {
soundFormats('mp3', 'ogg');
mySound1 = loadSound('re.mp3');
mySound2 = loadSound('si.mp3');
mySound3 = loadSound('do.mp3');
mySound4 = loadSound('c3.mp3');
mySound5 = loadSound('d6.mp3');
mySound6 = loadSound('sol.mp3');
mySound7 = loadSound('mi.mp3');
mySound8 = loadSound('c6.mp3');
mySound9 = loadSound('fa.mp3');
mySound0 = loadSound('la.mp3');
}
function setup() {
createCanvas(400, 400);
background(0);
}
function draw() {
if (shape == 1) {
fill('#E76F51');
ellipse(random(width), random(height), 50, 50);
} else if (shape == 2) {
fill('#2A9D8F');
triangle(random(width), random(height), random(width), random(height), random(width), random(height));
} else if (shape == 3) {
fill('#1D3557');
rect(random(width), random(height), 50, 50);
} else if (shape == 4) {
fill('#3A3C3D');
rect(random(width), random(height), 50, 50);
} else if (shape == 5) {
fill('#D5E4F3');
ellipse(random(width), random(height), 50, 50);
} else if (shape == 6) {
fill('#F9C80E');
rect(random(width), random(height), 50, 50);
}else if (shape == 7) {
fill('#6D4C41');
ellipse(random(width), random(height), 50, 50);
}else if (shape == 8) {
fill('#D90429');
triangle(random(width), random(height), random(width), random(height), random(width), random(height));
}else if (shape == 9) {
fill('#FFD2E1');
triangle(random(width), random(height), random(width), random(height), random(width), random(height));
}else if (shape == 0) {
fill('#E8DDB5');
ellipse(random(width), random(height), 50, 50);
}
}
function keyPressed() {
if (key == '1') {
shape = 1;
mySound1.play();
} else if (key == '2') {
shape = 2;
mySound2.play();
} else if (key == '3') {
shape = 3;
mySound3.play();
}else if (key == '4') {
shape = 4;
mySound4.play();
}else if (key == '5') {
shape = 5;
mySound5.play();
}else if (key == '6') {
shape = 6;
mySound6.play();
}else if (key == '7') {
shape = 7;
mySound7.play();
}else if (key == '8') {
shape = 8;
mySound8.play();
}else if (key == '9') {
shape = 9;
mySound9.play();
}else if (key == '0') {
shape = 0;
mySound0.play();
}
}