diff --git a/voicegardens/static/voicegardens.js b/voicegardens/static/voicegardens.js index 0118aa9..44dea70 100644 --- a/voicegardens/static/voicegardens.js +++ b/voicegardens/static/voicegardens.js @@ -269,10 +269,12 @@ class GeneratedShape { 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) { - return false; + return [false, undefined]; } for (let i = 0; i < shapes.length; i++) { @@ -292,16 +294,20 @@ class GeneratedShape { ); if (collision === true) { - return true; + return [true, shape]; } } + + return [false, undefined]; } sound() { /** * Play a sound after a collision is detected. **/ - return; // TODO: implement once again + if (this.recording.isLoaded()) { + this.recording.play(); + } } docolour() {