Browse Source

Towards shape collision sounds

main
Luke Murphy 5 years ago
parent
commit
491a612b19
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 9
      voicegardens/static/voicegardens.js

9
voicegardens/static/voicegardens.js

@ -241,6 +241,9 @@ class GeneratedShape {
// the sound recording attached to this shape
this.recording = recording;
// the shape that was last collided with
this.lastCollidedShape;
this.initialise();
}
@ -280,7 +283,7 @@ class GeneratedShape {
for (let i = 0; i < shapes.length; i++) {
let shape = shapes[i];
if (this === shape) {
if (this === shape || this.lastCollidedShape === shape) {
continue;
}
@ -294,6 +297,7 @@ class GeneratedShape {
);
if (collision === true) {
this.lastCollidedShape = shape;
return [true, shape];
}
}
@ -459,6 +463,9 @@ function draw() {
if (positionTick) {
shape.destX = random(windowWidth);
shape.destY = random(windowHeight);
// also reset last collided shape
shape.lastCollidedShape = undefined;
}
shape.draw();

Loading…
Cancel
Save