Browse Source

added ability for player to teleport in the tunnel

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

6
src/main/java/pacmanGame/Cell.java

@ -71,6 +71,12 @@ public class Cell {
else if(type.equals("crystal")) { else if(type.equals("crystal")) {
triggerCrystal(); triggerCrystal();
} }
else if(type.equals("tpLeft")) {
map.gameManager.teleportPlayer("tpRight");
}
else if(type.equals("tpRight")) {
map.gameManager.teleportPlayer("tpLeft");
}
else { else {
//System.out.println("cell contains no item!"); //System.out.println("cell contains no item!");

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

@ -72,6 +72,12 @@ public class GameManager {
} }
} }
public void teleportPlayer(String destination) {
player.position = map.findCellByString(destination).pos;
}
public boolean GhostPlayerColisionTest() { public boolean GhostPlayerColisionTest() {
for(int i = 0; i < ghosts.length; i++) { for(int i = 0; i < ghosts.length; i++) {

2
src/main/java/pacmanGame/VisualizerPlainText.java

@ -18,6 +18,8 @@ public class VisualizerPlainText implements Visualizer {
this.put("apple", "@ "); this.put("apple", "@ ");
this.put("crystal", "<>"); this.put("crystal", "<>");
this.put("pill", "o "); this.put("pill", "o ");
this.put("tpRight" , " ");
this.put("tpLeft" , " ");
}}; }};
public final String ghostSprite = "AA"; public final String ghostSprite = "AA";

Loading…
Cancel
Save