Comment, reshuffle shape drawing
This commit is contained in:
parent
2b3c235b50
commit
f45121a172
@ -438,6 +438,7 @@ function draw() {
|
|||||||
screenY = lerp(screenY, toScreenY, 0.2);
|
screenY = lerp(screenY, toScreenY, 0.2);
|
||||||
translate(screenX, screenY);
|
translate(screenX, screenY);
|
||||||
|
|
||||||
|
// generate a new shape after a sound recording
|
||||||
if (newSoundJustRecorded === true) {
|
if (newSoundJustRecorded === true) {
|
||||||
let newShape = new GeneratedShape();
|
let newShape = new GeneratedShape();
|
||||||
shapes.push(newShape);
|
shapes.push(newShape);
|
||||||
@ -448,19 +449,24 @@ function draw() {
|
|||||||
for (let i = 0; i < shapes.length; i++) {
|
for (let i = 0; i < shapes.length; i++) {
|
||||||
let shape = shapes[i];
|
let shape = shapes[i];
|
||||||
|
|
||||||
shape.draw();
|
// randomly move the shapes
|
||||||
shape.move();
|
|
||||||
|
|
||||||
if (positionTick) {
|
if (positionTick) {
|
||||||
shape.destX = random(windowWidth);
|
shape.destX = random(windowWidth);
|
||||||
shape.destY = random(windowHeight);
|
shape.destY = random(windowHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shape.collide(shapes) === true) {
|
shape.draw();
|
||||||
|
shape.move();
|
||||||
|
|
||||||
|
// play recordings when shapes collide
|
||||||
|
let [collision, collidedShape] = shape.collide(shapes);
|
||||||
|
if (collision === true) {
|
||||||
shape.sound();
|
shape.sound();
|
||||||
|
collidedShape.sound();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reset random shape position time ticker
|
||||||
positionTick = false;
|
positionTick = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user