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/Index.html b/Index.html index c68a28a..81c42ca 100644 --- a/Index.html +++ b/Index.html @@ -41,6 +41,7 @@
+
GAME PAUSED
Score: 0 diff --git a/script.js b/script.js index 84de7fd..e118bc6 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(); @@ -412,18 +419,21 @@ startBtn.onclick = () => { if (!animationId) loop(); } }; + +const pauseOverlay = document.getElementById('pause-overlay'); + pauseBtn.onclick = () => { - if (gameRunning) { - gameRunning = false; - pauseBtn.textContent = 'Resume'; - document.body.classList.remove('game-active'); - } else { - gameRunning = true; - pauseBtn.textContent = 'Pause'; - document.body.classList.add('game-active'); - if (!animationId) loop(); - } + if (gameRunning) { + gameRunning = false; + pauseBtn.textContent = 'Resume'; + pauseOverlay.classList.add('show'); + } else { + gameRunning = true; + pauseBtn.textContent = 'Pause'; + pauseOverlay.classList.remove('show'); + } }; + resetBtn.onclick = () => { gameRunning = false; pauseBtn.textContent = 'Pause'; 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 diff --git a/style.css b/style.css index 18d043d..7f929bc 100644 --- a/style.css +++ b/style.css @@ -214,7 +214,10 @@ main { } .game-btn:active { - transform: scale(0.96); + transform: translateY(1px); + background-color: #2aa314; + box-shadow: none; + transition: all 0.1s ease; } .game-btn:disabled { @@ -282,6 +285,32 @@ footer { font-size: 1.06em; } +#pause-overlay { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: rgba(0, 0, 0, 0.6); + display: flex; + justify-content: center; + align-items: center; + color: white; + font-size: 2em; + font-weight: bold; + text-shadow: 0 0 10px #000; + z-index: 10; + border-radius: 11px; + opacity: 0; + pointer-events: none; + transition: opacity 0.3s ease; +} +#pause-overlay.show { + opacity: 1; +} + + + @media (max-width:520px) { #game-area { min-width: unset; @@ -292,4 +321,5 @@ footer { max-width: 95vw; max-height: 89vw; } -} \ No newline at end of file +} +