From 012e6215880b970b7d2d86a8f24cf064987572be Mon Sep 17 00:00:00 2001 From: fdai7910 Date: Mon, 5 Feb 2024 22:18:18 +0100 Subject: [PATCH] added new crystal fruit --- src/main/java/pacmanGame/Cell.java | 10 ++++++++-- src/main/java/pacmanGame/GameManager.java | 5 +++-- src/main/java/pacmanGame/VisualizerPlainText.java | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/pacmanGame/Cell.java b/src/main/java/pacmanGame/Cell.java index ddafff3..0607d20 100644 --- a/src/main/java/pacmanGame/Cell.java +++ b/src/main/java/pacmanGame/Cell.java @@ -44,8 +44,11 @@ public class Cell { this.type = "empty"; map.gameManager.score += 205; } - - + public void triggerCrystal() { + this.type = "empty"; + map.gameManager.score += 506; + map.gameManager.moveSpeed = 3; + } public void triggerItem() { if(type.equals("dot")) { @@ -66,6 +69,9 @@ public class Cell { else if(type.equals("apple")) { triggerApple(); } + else if(type.equals("crystal")) { + triggerCrystal(); + } else { //System.out.println("cell contains no item!"); diff --git a/src/main/java/pacmanGame/GameManager.java b/src/main/java/pacmanGame/GameManager.java index 02c15a4..5206599 100644 --- a/src/main/java/pacmanGame/GameManager.java +++ b/src/main/java/pacmanGame/GameManager.java @@ -9,7 +9,7 @@ public class GameManager { public int score = 0; public boolean ghostIsEdible = false; public int timeStopPillEffect; - public int moveSpeed = 5; + public int moveSpeed; public GameManager() { setupGame(); @@ -17,6 +17,7 @@ public class GameManager { public void setupGame(){ time = 0; + moveSpeed = 5; map = new Map(Map.mapClassic,this); visualizer = new VisualizerPlainText(this); player = new Player(this); @@ -54,7 +55,7 @@ public class GameManager { } public String randomFruit() { - String fruitTypes[] = {"cherry","strawberry","orange","apple"}; + String fruitTypes[] = {"cherry","strawberry","orange","apple","crystal"}; int randomNumber = (int) (Math. random() * (fruitTypes.length)); return fruitTypes[randomNumber]; } diff --git a/src/main/java/pacmanGame/VisualizerPlainText.java b/src/main/java/pacmanGame/VisualizerPlainText.java index 527e711..d7c2ea3 100644 --- a/src/main/java/pacmanGame/VisualizerPlainText.java +++ b/src/main/java/pacmanGame/VisualizerPlainText.java @@ -16,6 +16,7 @@ public class VisualizerPlainText implements Visualizer { this.put("strawberry", "T7"); this.put("orange", "CO"); this.put("apple", "@ "); + this.put("crystal", "<>"); }}; public final String ghostSprite = "AA";