diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..30d74bc Binary files /dev/null and b/.DS_Store differ diff --git a/script.js b/script.js index 84de7fd..0e32247 100644 --- a/script.js +++ b/script.js @@ -17,6 +17,8 @@ document.onkeydown = preventDefaultForScrollKeys; })(); + + const firebaseConfig = { apiKey: "AIzaSyDRDvlwalRpidbThvTEMK6FZVsDnK5FSOQ", authDomain: "snakeevolution-90ebd.firebaseapp.com", @@ -329,11 +331,16 @@ function update() { document.getElementById('evoBox').textContent = ''; } } + + function playSound(){ + new Audio('sounds/eating_sound.wav').play(); + } // Self collision if (snake.some(seg => seg.x === head.x && seg.y === head.y)) return gameOver(); snake.unshift(head); // Eat food if (head.x === food.x && head.y === food.y) { + playSound() score++; document.getElementById('score').textContent = score; food = randomEmptyTile(); diff --git a/sounds/eating_sound.wav b/sounds/eating_sound.wav new file mode 100644 index 0000000..bac3f4f Binary files /dev/null and b/sounds/eating_sound.wav differ