diff --git a/index.html b/index.html
index 1a57140..f6190b6 100644
--- a/index.html
+++ b/index.html
@@ -18,7 +18,7 @@
-
+
diff --git a/sources/js/index.js b/sources/js/index.js
index a5760e2..d0fb3e5 100644
--- a/sources/js/index.js
+++ b/sources/js/index.js
@@ -6,6 +6,7 @@ const menuLevel = document.querySelector(".menu-level");
const gameZone = document.getElementById("game");
const score = document.getElementById("score");
const lives = document.getElementById("lives");
+const gameOver = document.getElementById("gameovermodal");
const audio = new Audio("sources/sound/main.mp3");
const startSound = new Audio("sources/sound/onStart.mp3");
const eatSound = new Audio("sources/sound/onEat.mp3");
@@ -13,7 +14,10 @@ const dieSound = new Audio("sources/sound/onDie.mp3");
const gameOverSound = new Audio("sources/sound/onGameOver.mp3");
const game = new Game(canvas);
+let gameOverModal;
+
+audio.loop = true;
startSound.volume = "0.2";
req.open("GET", "sources/levels.json");
@@ -54,7 +58,8 @@ game.onDie = lives => {
game.onGameOver = (score) => {
gameOverSound.play();
- alert(`Game over !\nYour score is: ${score}`);
+ gameOver.querySelector("span").innerText = score;
+ gameOverModal.open();
};
function loadLevels(levels) {
@@ -76,7 +81,7 @@ function loadGame(data) {
game.load(data);
game.start();
startSound.play();
-};
+}
function updateScore(s) {
score.innerText = s;
@@ -89,6 +94,7 @@ function updateLives(l) {
document.addEventListener('DOMContentLoaded', function() {
M.AutoInit();
+ gameOverModal = M.Modal.getInstance(gameOver);
canvas.width = gameZone.clientWidth;
canvas.height = gameZone.clientHeight;
});