diff --git a/assets/sounds/pop.mp3 b/assets/sounds/pop.mp3 new file mode 100644 index 00000000..202ac055 Binary files /dev/null and b/assets/sounds/pop.mp3 differ diff --git a/assets/testimonial-Favi.png b/assets/testimonial-Favi.png new file mode 100644 index 00000000..a4b0dc00 Binary files /dev/null and b/assets/testimonial-Favi.png differ diff --git a/js/game.js b/js/game.js index 7dbf1ce7..832f1d17 100644 --- a/js/game.js +++ b/js/game.js @@ -96,9 +96,6 @@ class Game { this.removeEventListener("boxFill"); clearInterval(this.timer); // Stop the timer - let winSound = new Audio("../assets/sounds/win.mp3"); - winSound.play(); - // Determine winner or draw const winner = this.determineWinner(this.players); @@ -112,7 +109,7 @@ class Game { this.playerTurnBgUI.classList.add("win"); this.playerTurnBgUI.style.background = winner.color; } - + // Storing winner data for leaderboard const playerData = JSON.parse(localStorage.getItem("playerData")); const player = playerData.find((player) => player.name === winner.name); @@ -120,9 +117,25 @@ class Game { playerData[playerIndex].score = winner.filledBoxes; playerData[playerIndex].winner = true; localStorage.setItem("winnerData", JSON.stringify(playerData)); + + // Winning Sound effect + let winSound = new Audio("../assets/sounds/win.mp3"); + winSound.play(); // Open the win overlay document.getElementById("win-overlay").style.height = "100%"; + + for (let i = 0; i < 10; i++) { + setTimeout(() => { + const pop = new Audio("../assets/sounds/pop.mp3"); + pop.play(); + confetti({ + particleCount: 200, + spread: 100, + origin: { y: 0.6 }, + }); + }, i * 1000); + } } determineWinner(players) { diff --git a/pages/game.html b/pages/game.html index 94479892..3f20291c 100644 --- a/pages/game.html +++ b/pages/game.html @@ -251,5 +251,6 @@