Browse Source

Added ghost number system in Map.java and GameManager.java

remotes/origin/ghosts
fdai7753 11 months ago
parent
commit
6b78ab00f8
  1. 19
      src/main/java/pacmanGame/GameManager.java
  2. 21
      src/main/java/pacmanGame/Ghost.java

19
src/main/java/pacmanGame/GameManager.java

@ -12,16 +12,15 @@ public class GameManager {
} }
public void setupGame(){ public void setupGame(){
map = new Map();
visualizer = new VisualizerPlainText(this);
player = new Player(this);
player.Spawn();
ghosts = new Ghost[4];
for(int i = 0; i < ghosts.length; i++) {
ghosts[i] = new Ghost(this);
}
}
map = new Map();
visualizer = new VisualizerPlainText(this);
player = new Player(this);
player.Spawn();
ghosts = new Ghost[4];
for (int i = 0; i < ghosts.length; i++) {
ghosts[i] = new Ghost(this, i);
}
}
public void Update() { public void Update() {
visualizer.Update(); visualizer.Update();
if(time%5 == 0) { if(time%5 == 0) {

21
src/main/java/pacmanGame/Ghost.java

@ -1,12 +1,21 @@
package pacmanGame; package pacmanGame;
public class Ghost { public class Ghost {
public Vector2 position;
public final GameManager gameManager;
public Vector2 position;
public final GameManager gameManager;
public final int ghostNumber;
public Ghost(GameManager gameManager) {
this.gameManager = gameManager;
this.position = new Vector2(-1, -1);
}
public Ghost(GameManager gameManager, int ghostNumber) {
this.gameManager = gameManager;
this.ghostNumber = ghostNumber;
this.position = new Vector2(-1, -1);
}
public void setPosition(Vector2 newPosition) {
this.position = newPosition;
}
public void move(Vector2 direction) {
this.position = this.position.Add(direction);
}
} }
Loading…
Cancel
Save