From 49c14a486ed4a728edfc5c51f351cbf2487d1d87 Mon Sep 17 00:00:00 2001 From: fdai2751 Date: Sun, 4 Feb 2024 18:39:51 +0100 Subject: [PATCH] added the togglePause fonction in to gameManager and changed the pause instruction on ESC --- src/main/java/pacmanGame/GameManager.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/pacmanGame/GameManager.java b/src/main/java/pacmanGame/GameManager.java index 2b6e210..ff8c542 100644 --- a/src/main/java/pacmanGame/GameManager.java +++ b/src/main/java/pacmanGame/GameManager.java @@ -35,8 +35,8 @@ public class GameManager { } public void ProcessInput(char inputChar) { - if(inputChar == 27) { - //todo: escape key pauses game + if(inputChar == 27) {// 27 = ESC + TogglePause(); } else if (inputChar == 'w' || inputChar == 's' || inputChar == 'd' || inputChar == 'a') { player.processInput(inputChar); @@ -68,5 +68,12 @@ public class GameManager { public void Unpause() { isPaused = false; } - + public void TogglePause() { + if(isPaused) { + Unpause(); + } + else { + Pause(); + } + } }