Browse Source

added new fruit apple

remotes/origin/player
fdai7910 11 months ago
parent
commit
379414258f
  1. 10
      src/main/java/pacmanGame/Cell.java
  2. 4
      src/main/java/pacmanGame/GameManager.java
  3. 1
      src/main/java/pacmanGame/VisualizerPlainText.java

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

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

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

Loading…
Cancel
Save