From 641b9cb0d85cf3f5e3c1f1356afb2e9ff27c229d Mon Sep 17 00:00:00 2001 From: Ray Arayilakath <72509475+RayhanADev@users.noreply.github.com> Date: Sun, 13 Jun 2021 14:25:49 +0000 Subject: [PATCH] fix: bug where game can be paused when ended (#8) --- .gitignore | 4 ++++ index.html | 2 +- offline/index.html | 2 +- service-worker.js | 2 ++ source/game.js | 4 ++-- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index dbb58ff..a8f642f 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,7 @@ node_modules/ # dotenv environment variables file .env + +# template html files +source/main.template.html +source/offline.template.html \ No newline at end of file diff --git a/index.html b/index.html index 9d32854..0774b5f 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -tether! \ No newline at end of file +tether! \ No newline at end of file diff --git a/offline/index.html b/offline/index.html index 6d19b33..6ddf983 100644 --- a/offline/index.html +++ b/offline/index.html @@ -1 +1 @@ - tether! \ No newline at end of file + tether! \ No newline at end of file diff --git a/service-worker.js b/service-worker.js index 5677cfd..996af1a 100644 --- a/service-worker.js +++ b/service-worker.js @@ -1,6 +1,8 @@ const cacheName = 'tether_cache-v2'; const precacheResources = [ + '/', '/offline/', + '/404.html', '/fonts/Quantico400.woff2', '/fonts/Quantico700.woff2', '/fonts/Tulpen-One400.woff2', diff --git a/source/game.js b/source/game.js index 61b0c0b..d6d7cee 100644 --- a/source/game.js +++ b/source/game.js @@ -2410,7 +2410,7 @@ function konamiSeq(requiredKey, givenKey) { function handleKey(e) { konamiSeq(konamiSequence[konamiLength], e.code); - if (e.code === 'KeyP') paused = !paused; + if (self.started && !self.ended && e.code === 'KeyP') paused = !paused; } document.addEventListener('click', handleClick); @@ -2466,7 +2466,7 @@ function animate() { y: game.lastMousePosition.y + 50, }); } - } else if (paused && pauseDelay !== 2) { + } else if (paused && pauseDelay !== 1) { game.step(); game.drawPauseMessage(); if (document.pointerLockElement) document.exitPointerLock();