From 379414258fe4c8215714711712699a695af528e7 Mon Sep 17 00:00:00 2001 From: fdai7910 Date: Mon, 5 Feb 2024 21:41:26 +0100 Subject: [PATCH] added new fruit apple --- src/main/java/pacmanGame/Cell.java | 10 +++++++++- src/main/java/pacmanGame/GameManager.java | 4 ++-- src/main/java/pacmanGame/VisualizerPlainText.java | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/pacmanGame/Cell.java b/src/main/java/pacmanGame/Cell.java index 6e2ed06..23f698e 100644 --- a/src/main/java/pacmanGame/Cell.java +++ b/src/main/java/pacmanGame/Cell.java @@ -40,6 +40,11 @@ public class Cell { map.gameManager.score += 305; } + public void triggerApple() { + this.type = "empty"; + map.gameManager.score += 205; + } + public void triggerItem() { if(type.equals("dot")) { triggerDot(); @@ -54,7 +59,10 @@ public class Cell { triggerStrawberry(); } else if(type.equals("orange")) { - triggerStrawberry(); + triggerOrange(); + } + else if(type.equals("apple")) { + triggerApple(); } 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 af69fb1..db231b4 100644 --- a/src/main/java/pacmanGame/GameManager.java +++ b/src/main/java/pacmanGame/GameManager.java @@ -30,7 +30,7 @@ public class GameManager { if(time%5 == 0) { player.Move(); } - if(time == 30) { + if(time == 300) { spawnFruit(); } if (time == 600) { @@ -52,7 +52,7 @@ public class GameManager { } public String randomFruit() { - String fruitTypes[] = {"cherry","strawberry","orange"}; + String fruitTypes[] = {"cherry","strawberry","orange","apple"}; 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 283d761..527e711 100644 --- a/src/main/java/pacmanGame/VisualizerPlainText.java +++ b/src/main/java/pacmanGame/VisualizerPlainText.java @@ -15,6 +15,7 @@ public class VisualizerPlainText implements Visualizer { this.put("cherry", "OO"); this.put("strawberry", "T7"); this.put("orange", "CO"); + this.put("apple", "@ "); }}; public final String ghostSprite = "AA";