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";
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!");
}
}
}

6
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];
}

1
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";

Loading…
Cancel
Save