Browse Source

Use tuple for playing both collided shape sounds

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

14
voicegardens/static/voicegardens.js

@ -269,10 +269,12 @@ class GeneratedShape {
collide(shapes) { collide(shapes) {
/** /**
* Detect if the shape collides with another shape. * Detect if the shape collides with another shape. Returns a tuple of type
* [bool, shape] where bool = if there was a collision and shape = the
* collided shape.
**/ **/
if (shapes.length === 1) { if (shapes.length === 1) {
return false; return [false, undefined];
} }
for (let i = 0; i < shapes.length; i++) { for (let i = 0; i < shapes.length; i++) {
@ -292,16 +294,20 @@ class GeneratedShape {
); );
if (collision === true) { if (collision === true) {
return true; return [true, shape];
} }
} }
return [false, undefined];
} }
sound() { sound() {
/** /**
* Play a sound after a collision is detected. * Play a sound after a collision is detected.
**/ **/
return; // TODO: implement once again if (this.recording.isLoaded()) {
this.recording.play();
}
} }
docolour() { docolour() {

Loading…
Cancel
Save