From f465b34be027e235081eb68d6a06eec91769a9a8 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Wed, 3 Apr 2019 12:46:07 -0700 Subject: [PATCH] cleaned up a bit of pausing logic --- Engine.js | 13 ++++--------- Touch.js | 6 +----- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Engine.js b/Engine.js index e82df06..4694c57 100755 --- a/Engine.js +++ b/Engine.js @@ -54,7 +54,8 @@ renderer.bg = function() { screen.drawImage(this.gfx.bg, this.bgx, 0); screen.drawImage(this.gfx.bg, this.bgx + 1472, 0); - this.bgx -= 8; + if (!gameState.paused){ + this.bgx -= 8;} if (this.bgx == -1472) this.bgx = 0; } @@ -208,9 +209,7 @@ function loop() else { if (!gameState.over){ - if (gameState.paused) { renderer.bgPaused()} - else{ - renderer.bg()}; + renderer.bg(); if (!gameState.paused) { catbug.move(); @@ -292,11 +291,7 @@ function pressHandler(e) { if (gameState.playing) { - if (!gameState.paused) - { - gameState.paused = true; - } - else{ gameState.paused = false; } + gameState.paused = !gameState.paused } } break; diff --git a/Touch.js b/Touch.js index dc9dcb8..ad37da9 100644 --- a/Touch.js +++ b/Touch.js @@ -145,11 +145,7 @@ function pressPause(e) { if (gameState.playing) { - if (!gameState.paused) - { - gameState.paused = true; - } - else{ gameState.paused = false; } + gameState.paused = !gameState.paused; } }