let welcheForm = [0, 1, 2, 3];
let soundsPath1 = ['schnips1.mp3', 'audio01.wav','audio03.wav','audio04.wav','audio05.wav','audio13.wav','audio14.wav','audio15.wav','audio16.wav','audio17.wav','audio18.wav','audio19.wav','audio20.wav','audio21.wav','audio22.wav','audio23.wav','audio24.wav','audio25.wav','a-saite.mp3','d-saite.mp3','e-saite.mp3','g-saite.mp3','geige_dsaite.mp3','geige_gsaite.mp3','Unbenannt 5.mp3','audio26.wav'];
let soundsPath2 = ['piano01.wav', 'piano02.wav', 'piano03.mp3', 'piano04.wav', 'piano05.wav', 'piano06.wav', 'piano07.wav', 'piano08.wav', 'piano09.wav', 'piano10.wav', 'piano11.wav', 'piano12.wav', 'piano13.wav', 'piano14.wav', 'piano15.wav', 'piano16.wav', 'piano17.wav', 'piano18.wav', 'piano19.wav', 'piano20.wav', 'piano21.wav', 'piano22.wav', 'piano23.wav', 'piano24.wav', 'piano25.wav'];
let oldMouseX, oldMouseY;
let buttonLRStop = false;
let buttonUDStop = false;
let buttonRAStop = false;
for (i = 0; i < soundsPath1.length; i++) {
loadedSounds1[j] = loadSound(soundsPath1[j]);
loadedSounds1[j].playMode('restart');
for (i = 0; i < soundsPath2.length; i++) {
loadedSounds2[j] = loadSound(soundsPath2[j]);
loadedSounds2[j].playMode('restart');
createCanvas(windowWidth, windowHeight);
for (let i = 1; i < scaleWidth - 1; i++) {
slots1.push(new slots(i, 1, i));
for (let i = 1; i < scaleHeight - 1; i++) {
slots1.push(new slots(i, 2, i));
for (let i = 1; i < scaleWidth - 1; i++) {
slots1.push(new slots(i, 3, i));
for (let i = 1; i < scaleHeight - 1; i++) {
slots1.push(new slots(i, 4, i));
boxWidth = width / scaleWidth;
boxHeight = height / scaleHeight;
for (j = 0; j < slots1.length; j++) {
for (j = 0; j < forme.length; j++) {
if (buttonUDStop == false) {
} else if (buttonUDStop == true) {
if (buttonLRStop == false) {
} else if (buttonLRStop == true) {
buttonRemoveLast(255, 0);
function buttonRemoveLast(fRecht, fLinie) {
rect(0, 0, boxWidth, boxHeight);
line(boxWidth / 10, boxHeight / 10, boxWidth - boxWidth / 10, boxHeight - boxHeight / 10);
line(boxWidth / 10, boxHeight - boxHeight / 10, boxWidth - boxWidth / 10, boxHeight / 10);
function buttonRemoveAll(fRecht, fLinie) {
rect(width - boxWidth, 0, width, boxHeight);
line(width - boxWidth / 10, boxHeight / 10, width - boxWidth + boxWidth / 10, boxHeight - boxHeight / 10);
line(width - boxWidth / 10, boxHeight - boxHeight / 10, width - boxWidth + boxWidth / 10, boxHeight / 10);
function buttonUpDown(fRecht, fTria) {
rect(0, height - boxHeight, boxWidth, boxHeight);
triangle(boxWidth / 4, height - boxHeight / 8 * 4.5, boxWidth / 2, height - boxHeight / 8 * 7, boxWidth / 4 * 3, height - boxHeight / 8 * 4.5);
triangle(boxWidth / 4, height - boxHeight / 8 * 3.5, boxWidth / 2, height - boxHeight / 8, boxWidth / 4 * 3, height - boxHeight / 8 * 3.5);
function buttonLeftRight(fRecht, fTria) {
rect(width - boxWidth, height - boxHeight, boxWidth, boxHeight);
triangle(width - boxWidth / 8 * 3.5, height - boxHeight / 4 * 3, width - boxWidth / 8, height - boxHeight / 2, width - boxWidth / 8 * 3.5, height - boxHeight / 4);
triangle(width - boxWidth / 8 * 4.5, height - boxHeight / 4 * 3, width - boxWidth / 8 * 7, height - boxHeight / 2, width - boxWidth / 8 * 4.5, height - boxHeight / 4);
forme.splice(0, forme.length);
for (let i = 0; i < loadedSounds1.length; i++) {
forme.splice(forme.length - 1, 1);
if (keyCode === UP_ARROW || keyCode === DOWN_ARROW) {
} else if (keyCode === LEFT_ARROW || keyCode === RIGHT_ARROW) {
function cross(xOrigin, yOrigin) {
let movementSpeed = dist(xOrigin, yOrigin, mouseX, mouseY) / 10;
let useableMouseX = mouseX + xOrigin;
let useableMouseY = mouseY + yOrigin;
if (mouseX > xOrigin && mouseY > yOrigin) {
if (mouseX > xOrigin && mouseY < yOrigin) {
if (mouseX < xOrigin && mouseY > yOrigin) {
if (mouseX < xOrigin && mouseY < yOrigin) {
function touchControl(x, y) {
if (x >= 0 && x <= boxWidth && y >= 0 && y <= boxHeight) {
} else if (x >= width - boxWidth && x <= width && y >= 0 && y <= boxHeight) {
} else if (x >= width - boxWidth && x <= width && y >= height - boxHeight && y <= height) {
} else if (x >= 0 && x <= boxWidth && y >= boxHeight && y <= height) {
function startUpForm(x, y) {
if (x > boxWidth && x < width - boxWidth && y > boxHeight && y < height - boxHeight) {
wFormToPush = random(welcheForm);
forms(wFormToPush, oldMouseX, oldMouseY, wFarbe, 3);
line(oldMouseX, oldMouseY, mouseX, mouseY);
dx = -(oldMouseX - mouseX) / 10;
dy = -(oldMouseY - mouseY) / 10;
if (buttonLRStop == true && buttonUDStop == true) {
cross(oldMouseX, oldMouseY);
function mousePressed() {
for (let i = 0; i < slots1.length; i++) {
slots1[i].clicked(mouseX, mouseY);
startUpForm(mouseX, mouseY);
touchControl(mouseX, mouseY);
function mouseReleased() {
forme.push(new formen(oldMouseX, oldMouseY, dx, dy, wFormToPush, wFarbe));
if (keyCode === BACKSPACE) {
preset = (preset + 1) % 2;
if (keyIsDown(SHIFT) && keyIsDown(BACKSPACE)) {
function forms(whichForm, welcheX, welcheY, welcheFarbe, welcheR) {
let grösse = scaleGlobal / 25;
stroke(welcheFarbe, 100, 100);
fill(welcheFarbe, 100, 100);
circle(welcheX, welcheY, grösse);
} else if (whichForm == 1) {
translate(welcheX, welcheY);
rect(0, 0, grösse, grösse);
} else if (whichForm == 2) {
translate(welcheX, welcheY);
triangle(-grösse / 5 * 3, -grösse / 5 * 2, grösse / 5 * 3, -grösse / 5 * 2, 0, grösse / 5 * 2);
} else if (whichForm == 3) {
translate(welcheX, welcheY);
triangle(-grösse / 5 * 3, -grösse / 10 * 3, grösse / 5 * 3, -grösse / 10 * 3, 0, grösse / 5 * 3);
triangle(0, -grösse / 5 * 3, -grösse / 5 * 3, grösse / 10 * 3, grösse / 5 * 3, grösse / 10 * 3);
constructor(x1, y1, dx1, dy1, form, farbe) {
this.rRandom = random(5);
if (this.x < width / (scaleWidth - 1) + scaleGlobal / 50) {
for (let i = slots1.length - (scaleHeight - 1); i < slots1.length; i++) {
if (this.y >= slots1[i].posYU && this.y <= slots1[i].posYD) {
if (this.x > width - width / (scaleWidth - 1) - scaleGlobal / 50) {
for (let i = scaleWidth - 2; i < scaleWidth - 2 + scaleHeight - 2; i++) {
if (this.y >= slots1[i].posYU && this.y <= slots1[i].posYD) {
if (this.y < height / (scaleHeight - 1) + scaleGlobal / 50) {
for (let i = 0; i < scaleWidth - 2; i++) {
if (this.x >= slots1[i].posXL && this.x <= slots1[i].posXR) {
if (this.y > height - height / (scaleHeight - 1) - scaleGlobal / 50) {
for (let i = scaleWidth - 2 + scaleHeight - 2; i < 2 * scaleWidth - 4 + scaleHeight - 2; i++) {
if (this.x >= slots1[i].posXL && this.x <= slots1[i].posXR) {
loadedSounds1[slots1[number].whatSound].play();
} else if (this.preset == 1) {
loadedSounds2[slots1[number].whatSound].play();
this.x = this.x + this.dx;
this.y = this.y + this.dy;
stroke(this.farbe, 100, 100);
fill(this.farbe, 100, 100);
this.r = this.r + this.rRandom;
forms(this.welcheForm, this.x, this.y, this.farbe, this.r);
constructor(slot, wall, whatCount) {
this.whatCount = whatCount;
this.posXL = width / scaleWidth * this.slot;
this.posXR = width / scaleWidth * (this.slot + 1);
this.posYU = height / scaleHeight * this.slot;
this.posYD = height / scaleHeight * (this.slot + 1);
this.posY = height / scaleHeight * this.slot;
if (this.wall == 1 && y <= boxHeight && x >= this.posXL && x <= this.posXR) {
this.whatCount = this.whatCount + 1;
} else if (this.wall == 3 && y >= height - boxHeight && x >= this.posXL && x <= this.posXR) {
this.whatCount = this.whatCount + 1;
} else if (this.wall == 2 && x >= width - boxWidth && y >= this.posYU && y <= this.posYD) {
this.whatCount = this.whatCount + 1;
} else if (this.wall == 4 && x <= boxWidth && y >= this.posYU && y <= this.posYD) {
this.whatCount = this.whatCount + 1;
this.whatCount = this.whatCount % 25;
this.whatColor = this.whatCount * 4;
this.whatSound = this.whatCount;
fill(this.whatColor, 100, 100);
rect(this.posXL, 0, this.posXR, boxHeight);
} else if (this.wall == 2) {
rect(width - boxWidth, this.posY, width, boxHeight);
} else if (this.wall == 3) {
rect(this.posXL, height - boxHeight, boxWidth, height);
} else if (this.wall == 4) {
rect(0, this.posY, boxWidth, boxHeight);