From d7ada21496e36b363c4839c3ace86474a2fd83d3 Mon Sep 17 00:00:00 2001 From: flifloo Date: Sat, 27 Mar 2021 11:08:55 +0100 Subject: [PATCH] Add speed display --- index.html | 1 + sources/js/index.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/index.html b/index.html index 54484c2..214b0bf 100644 --- a/index.html +++ b/index.html @@ -12,6 +12,7 @@

Score:

Lives:

+

Speed:

KyFlo Snake

diff --git a/sources/js/index.js b/sources/js/index.js index 3e156d9..350c397 100644 --- a/sources/js/index.js +++ b/sources/js/index.js @@ -9,6 +9,7 @@ const lives = document.getElementById("lives"); const gameOver = document.getElementById("gameovermodal"); const scoreBoard = document.getElementById("scoreboard"); const playerName = document.querySelector("input"); +const speed = document.getElementById("speed"); const audio = new Audio("sources/sound/main.mp3"); const startSound = new Audio("sources/sound/onStart.mp3"); const eatSound = new Audio("sources/sound/onEat.mp3"); @@ -107,6 +108,7 @@ function loadGame(data) { function updateScore(s) { score.innerText = `Score: ${s}`; + speed.innerText = `Speed: ${game.snakeSpeed} ms`; } function updateLives(l) {