Browse Source

added strawberry fruit type

remotes/origin/player
fdai7910 11 months ago
parent
commit
d1fc48f36d
  1. 13
      src/main/java/pacmanGame/Cell.java
  2. 6
      src/main/java/pacmanGame/GameManager.java
  3. 1
      src/main/java/pacmanGame/VisualizerPlainText.java

13
src/main/java/pacmanGame/Cell.java

@ -25,11 +25,16 @@ public class Cell {
} }
public void triggerFruit() {
public void triggerCherry() {
this.type = "empty"; this.type = "empty";
map.gameManager.score += 505; map.gameManager.score += 505;
} }
public void triggerStrawberry() {
this.type = "empty";
map.gameManager.score += 405;
}
public void triggerItem() { public void triggerItem() {
if(type.equals("dot")) { if(type.equals("dot")) {
triggerDot(); triggerDot();
@ -38,10 +43,14 @@ public class Cell {
triggerPill(); triggerPill();
} }
else if(type.equals("cherry")) { else if(type.equals("cherry")) {
triggerFruit();
triggerCherry();
}
else if(type.equals("strawberry")) {
triggerStrawberry();
} }
else { else {
//System.out.println("cell contains no item!"); //System.out.println("cell contains no item!");
} }
} }
} }

6
src/main/java/pacmanGame/GameManager.java

@ -30,7 +30,7 @@ public class GameManager {
if(time%5 == 0) { if(time%5 == 0) {
player.Move(); player.Move();
} }
if(time == 300) {
if(time == 30) {
spawnFruit(); spawnFruit();
} }
if (time == 600) { if (time == 600) {
@ -52,8 +52,8 @@ public class GameManager {
} }
public String randomFruit() { 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]; return fruitTypes[randomNumber];
} }

1
src/main/java/pacmanGame/VisualizerPlainText.java

@ -13,6 +13,7 @@ public class VisualizerPlainText implements Visualizer {
this.put("dot", ". "); this.put("dot", ". ");
this.put("wall", "[]"); this.put("wall", "[]");
this.put("cherry", "OO"); this.put("cherry", "OO");
this.put("strawberry", "T7");
}}; }};
public final String ghostSprite = "AA"; public final String ghostSprite = "AA";

Loading…
Cancel
Save