Browse Source

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

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

5
src/main/java/pacmanGame/GameManager.java

@ -17,10 +17,9 @@ public class GameManager {
player = new Player(this); player = new Player(this);
player.Spawn(); player.Spawn();
ghosts = new Ghost[4]; ghosts = new Ghost[4];
for(int i = 0; i < ghosts.length; i++) {
ghosts[i] = new Ghost(this);
for (int i = 0; i < ghosts.length; i++) {
ghosts[i] = new Ghost(this, i);
} }
} }
public void Update() { public void Update() {
visualizer.Update(); visualizer.Update();

11
src/main/java/pacmanGame/Ghost.java

@ -3,10 +3,19 @@ package pacmanGame;
public class Ghost { public class Ghost {
public Vector2 position; public Vector2 position;
public final GameManager gameManager; public final GameManager gameManager;
public final int ghostNumber;
public Ghost(GameManager gameManager) {
public Ghost(GameManager gameManager, int ghostNumber) {
this.gameManager = gameManager; this.gameManager = gameManager;
this.ghostNumber = ghostNumber;
this.position = new Vector2(-1, -1); 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