From d1fc48f36d6bfe081d6f165b6ecc19dafb87d107 Mon Sep 17 00:00:00 2001 From: fdai7910 Date: Mon, 5 Feb 2024 21:33:52 +0100 Subject: [PATCH] added strawberry fruit type --- src/main/java/pacmanGame/Cell.java | 13 +++++++++++-- src/main/java/pacmanGame/GameManager.java | 6 +++--- src/main/java/pacmanGame/VisualizerPlainText.java | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/pacmanGame/Cell.java b/src/main/java/pacmanGame/Cell.java index f9cd74b..8c427b0 100644 --- a/src/main/java/pacmanGame/Cell.java +++ b/src/main/java/pacmanGame/Cell.java @@ -25,11 +25,16 @@ public class Cell { } - public void triggerFruit() { + public void triggerCherry() { this.type = "empty"; map.gameManager.score += 505; } + public void triggerStrawberry() { + this.type = "empty"; + map.gameManager.score += 405; + } + public void triggerItem() { if(type.equals("dot")) { triggerDot(); @@ -38,10 +43,14 @@ public class Cell { triggerPill(); } else if(type.equals("cherry")) { - triggerFruit(); + triggerCherry(); + } + else if(type.equals("strawberry")) { + triggerStrawberry(); } 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 7f11a92..c79f8e6 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 == 300) { + if(time == 30) { spawnFruit(); } if (time == 600) { @@ -52,8 +52,8 @@ public class GameManager { } public String randomFruit() { - String fruitTypes[] = {"cherry"}; - int randomNumber = (int) (Math. random() * fruitTypes.length); + String fruitTypes[] = {"cherry","strawberry"}; + 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 9bcc354..e5f315a 100644 --- a/src/main/java/pacmanGame/VisualizerPlainText.java +++ b/src/main/java/pacmanGame/VisualizerPlainText.java @@ -13,6 +13,7 @@ public class VisualizerPlainText implements Visualizer { this.put("dot", ". "); this.put("wall", "[]"); this.put("cherry", "OO"); + this.put("strawberry", "T7"); }}; public final String ghostSprite = "AA";