From 9b36ee55f4f12d48d0c692eeb4282c59223905ed Mon Sep 17 00:00:00 2001 From: fdai7910 Date: Mon, 5 Feb 2024 21:55:11 +0100 Subject: [PATCH] added game restart key --- src/main/java/pacmanGame/GameManager.java | 6 ++++-- src/main/java/pacmanGame/Player.java | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/pacmanGame/GameManager.java b/src/main/java/pacmanGame/GameManager.java index db231b4..02c15a4 100644 --- a/src/main/java/pacmanGame/GameManager.java +++ b/src/main/java/pacmanGame/GameManager.java @@ -9,12 +9,14 @@ public class GameManager { public int score = 0; public boolean ghostIsEdible = false; public int timeStopPillEffect; + public int moveSpeed = 5; public GameManager() { setupGame(); } public void setupGame(){ + time = 0; map = new Map(Map.mapClassic,this); visualizer = new VisualizerPlainText(this); player = new Player(this); @@ -27,7 +29,7 @@ public class GameManager { public void Update() { visualizer.Update(); - if(time%5 == 0) { + if(time%moveSpeed == 0) { player.Move(); } if(time == 300) { @@ -61,7 +63,7 @@ public class GameManager { if(inputChar == 27) { //todo: escape key pauses game } - else if (inputChar == 'w' || inputChar == 's' || inputChar == 'd' || inputChar == 'a') { + else if (inputChar == 'w' || inputChar == 's' || inputChar == 'd' || inputChar == 'a' || inputChar == 'r') { player.processInput(inputChar); } else { diff --git a/src/main/java/pacmanGame/Player.java b/src/main/java/pacmanGame/Player.java index 411f504..3731680 100644 --- a/src/main/java/pacmanGame/Player.java +++ b/src/main/java/pacmanGame/Player.java @@ -48,6 +48,9 @@ public class Player { else if(inputchar == 'a') { checkInput(new Vector2(-1,0)); } + else if(inputchar == 'r') { + gameManager.setupGame(); + } }