NeilFraser / beaver-games

A collection of simple games for young children.
https://beaver.games/
Apache License 2.0
58 stars 14 forks source link

Fix hard-mode sound playing in snake #4

Closed fabianschwarzfritz closed 3 years ago

fabianschwarzfritz commented 3 years ago

Before the commit/content: Thanks for this great and fun little project 😄 !

There is a bug in the coding: When playing snake in hard mode, and two apples where right next to each other, the player can only hear one sound. The player should hear both apple-eating sounds.

Again, this bug only appeared in hard-mode. To reproduce, I have manually put two apples next to each other in the field (position x, y and x+1, y) and steered snake horizontally over the two apples.

This fix implemented as part of this commit is to pause the first sound if playing, reset the audio and play again. With this, the player at least hears the beginning of one sound and the full second sound.

@NeilFraser please let me know if there's anything else to test or you'd prefer another implementation to fix this bug 😄 . Great games by the way!