From 7b8364cb96338ac02690e6f8b27c197ee2d27526 Mon Sep 17 00:00:00 2001 From: fdai2751 Date: Mon, 5 Feb 2024 22:52:19 +0100 Subject: [PATCH 1/7] added update fonction inside GameManager --- src/main/java/pacmanGame/GameManager.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/pacmanGame/GameManager.java b/src/main/java/pacmanGame/GameManager.java index ff8c542..62063b7 100644 --- a/src/main/java/pacmanGame/GameManager.java +++ b/src/main/java/pacmanGame/GameManager.java @@ -27,9 +27,11 @@ public class GameManager { } public void Update() { - visualizer.Update(); - if(time%5 == 0) { - player.Move(); + if(!isPaused) { + visualizer.Update(); + if(time%5 == 0) { + player.Move(); + } } time++; } From c5bf23fb08ed635455d19e0f1938062154b0e5ad Mon Sep 17 00:00:00 2001 From: fdai2751 Date: Mon, 5 Feb 2024 23:25:42 +0100 Subject: [PATCH 2/7] display paused state --- .../java/pacmanGame/VisualizerPlainText.java | 54 ++++++++++++------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/src/main/java/pacmanGame/VisualizerPlainText.java b/src/main/java/pacmanGame/VisualizerPlainText.java index 7591711..33514d9 100644 --- a/src/main/java/pacmanGame/VisualizerPlainText.java +++ b/src/main/java/pacmanGame/VisualizerPlainText.java @@ -36,30 +36,44 @@ public class VisualizerPlainText implements Visualizer { for(int y = 0; y < map.size.y; y++) { for(int x = 0; x < map.size.x; x++) { Cell cell = map.GetCell(new Vector2(x, map.size.y - 1 - y)); - boolean containsGhosts = false; - boolean containsPlayer = false; - for( int i = 0; i < gameManager.ghosts.length; i++) { - if(gameManager.ghosts[i].position.equals(cell.pos)) { - containsGhosts = true; - } - } - if(gameManager.player.position.equals(cell.pos)) { - containsPlayer = true; - } - if(containsPlayer) { - output += playerSprite; - } - else if(containsGhosts) { - output += ghostSprite; - } - else if (sprites.containsKey(cell.type)) { - - output += sprites.get(cell.type); + if(gameManager.isPaused && 5 < y && y <= 10){ + if(x == 0) { + if(y == 8){ + output += "Game Paused!"; + } + else { + output += ""; + } + } } else { - System.out.println("unknown type" + cell.type); + boolean containsGhosts = false; + boolean containsPlayer = false; + for( int i = 0; i < gameManager.ghosts.length; i++) { + if(gameManager.ghosts[i].position.equals(cell.pos)) { + containsGhosts = true; + } + } + if(gameManager.player.position.equals(cell.pos)) { + containsPlayer = true; + } + + if(containsPlayer) { + output += playerSprite; + } + else if(containsGhosts) { + output += ghostSprite; + } + else if (sprites.containsKey(cell.type)) { + + output += sprites.get(cell.type); + } + else { + System.out.println("unknown type" + cell.type); + } } + } output += "\n"; } From 2252f665fcd6f2d99d51982eee736c8804c46a67 Mon Sep 17 00:00:00 2001 From: fdai2751 Date: Wed, 7 Feb 2024 16:35:32 +0100 Subject: [PATCH 3/7] remaining Lives and failed Attempts --- src/main/java/pacmanGame/GameManager.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/java/pacmanGame/GameManager.java b/src/main/java/pacmanGame/GameManager.java index 62063b7..9fb1d97 100644 --- a/src/main/java/pacmanGame/GameManager.java +++ b/src/main/java/pacmanGame/GameManager.java @@ -8,9 +8,13 @@ public class GameManager { public Player player; public int score = 0; public boolean isPaused; + public int livesRemaining; + public int failedAttempts; public GameManager() { - setupGame(); + livesRemaining = 3; + failedAttempts = 0; + setupGame(); } public void setupGame(){ @@ -22,10 +26,20 @@ public class GameManager { for(int i = 0; i < ghosts.length; i++) { ghosts[i] = new Ghost(this); } - isPaused = false; - + isPaused = false; + } + /* public void handleGhostCollision() { + livesRemaining--; // Reduziere verbleibende leben um 1 + failedAttempts++; // Erhöhe die Anzahl der Fehlversuche + if(livesRemaining <= 0) { + gameOver(); //wenn Keine Leben mehr übrig sind. + } } + public void gameOver() { + // todo + } + */ public void Update() { if(!isPaused) { visualizer.Update(); From c5b9f36906b6158a0ab55ddc352aa4cfd0631a6a Mon Sep 17 00:00:00 2001 From: fdai2751 Date: Wed, 7 Feb 2024 16:40:52 +0100 Subject: [PATCH 4/7] added the Ghostcollision function --- src/main/java/pacmanGame/GameManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/pacmanGame/GameManager.java b/src/main/java/pacmanGame/GameManager.java index 9fb1d97..7998a74 100644 --- a/src/main/java/pacmanGame/GameManager.java +++ b/src/main/java/pacmanGame/GameManager.java @@ -28,15 +28,15 @@ public class GameManager { } isPaused = false; } - /* public void handleGhostCollision() { + public void handleGhostCollision() { livesRemaining--; // Reduziere verbleibende leben um 1 failedAttempts++; // Erhöhe die Anzahl der Fehlversuche if(livesRemaining <= 0) { - gameOver(); //wenn Keine Leben mehr übrig sind. + // gameOver(); //wenn Keine Leben mehr übrig sind. } } - public void gameOver() { + /* public void gameOver() { // todo } */ From 9638fd70fe29c0ad21bc1e578316ddfb0f137645 Mon Sep 17 00:00:00 2001 From: fdai2751 Date: Wed, 7 Feb 2024 16:43:17 +0100 Subject: [PATCH 5/7] added the Gameover function --- src/main/java/pacmanGame/GameManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/pacmanGame/GameManager.java b/src/main/java/pacmanGame/GameManager.java index 7998a74..0fc1d39 100644 --- a/src/main/java/pacmanGame/GameManager.java +++ b/src/main/java/pacmanGame/GameManager.java @@ -36,10 +36,10 @@ public class GameManager { } } - /* public void gameOver() { + public void gameOver() { // todo } - */ + public void Update() { if(!isPaused) { visualizer.Update(); From f1e91dd3c138e5ce864ffb8f53f00376e1424de0 Mon Sep 17 00:00:00 2001 From: fdai2751 Date: Wed, 7 Feb 2024 17:01:40 +0100 Subject: [PATCH 6/7] =?UTF-8?q?chek=20the=20livesnumber=C2=B4s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pacmanGame/GameManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/pacmanGame/GameManager.java b/src/main/java/pacmanGame/GameManager.java index 0fc1d39..f71c687 100644 --- a/src/main/java/pacmanGame/GameManager.java +++ b/src/main/java/pacmanGame/GameManager.java @@ -32,12 +32,12 @@ public class GameManager { livesRemaining--; // Reduziere verbleibende leben um 1 failedAttempts++; // Erhöhe die Anzahl der Fehlversuche if(livesRemaining <= 0) { - // gameOver(); //wenn Keine Leben mehr übrig sind. + gameOver(); //wenn Keine Leben mehr übrig sind. } } public void gameOver() { - // todo + System.out.println("Das Spiel ist vorbei! Pech!!"); } public void Update() { From 94b38e1f2a05d18afaa67463c5b4dc896dc01d47 Mon Sep 17 00:00:00 2001 From: fdai7012 Date: Wed, 7 Feb 2024 17:52:13 +0100 Subject: [PATCH 7/7] fixed compile error from merge --- src/main/java/pacmanGame/GameManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/pacmanGame/GameManager.java b/src/main/java/pacmanGame/GameManager.java index c198021..5607b62 100644 --- a/src/main/java/pacmanGame/GameManager.java +++ b/src/main/java/pacmanGame/GameManager.java @@ -25,15 +25,15 @@ public class GameManager { player.Spawn(); ghosts = new Ghost[4]; for(int i = 0; i < ghosts.length; i++) { - ghosts[i] = new Ghost(this); + ghosts[i] = new Ghost(this, 1); } isPaused = false; } public void handleGhostCollision() { livesRemaining--; // Reduziere verbleibende leben um 1 - failedAttempts++; // Erhöhe die Anzahl der Fehlversuche + failedAttempts++; // Erh�he die Anzahl der Fehlversuche if(livesRemaining <= 0) { - gameOver(); //wenn Keine Leben mehr übrig sind. + gameOver(); //wenn Keine Leben mehr �brig sind. } }