Skip to content

Commit

Permalink
fix: bug where game can be paused when ended (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
rayhanadev committed Jun 13, 2021
1 parent 61377c7 commit 641b9cb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,7 @@ node_modules/

# dotenv environment variables file
.env

# template html files
source/main.template.html
source/offline.template.html
2 changes: 1 addition & 1 deletion index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion offline/index.html

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions service-worker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const cacheName = 'tether_cache-v2';
const precacheResources = [
'/',
'/offline/',
'/404.html',
'/fonts/Quantico400.woff2',
'/fonts/Quantico700.woff2',
'/fonts/Tulpen-One400.woff2',
Expand Down
4 changes: 2 additions & 2 deletions source/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 641b9cb

Please sign in to comment.