diff --git a/src/main/java/pacmanGame/GameManager.java b/src/main/java/pacmanGame/GameManager.java index 8a154d5..739359c 100644 --- a/src/main/java/pacmanGame/GameManager.java +++ b/src/main/java/pacmanGame/GameManager.java @@ -12,16 +12,15 @@ public class GameManager { } 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() { visualizer.Update(); if(time%5 == 0) { diff --git a/src/main/java/pacmanGame/Ghost.java b/src/main/java/pacmanGame/Ghost.java index dc8a7d9..9e7f6b3 100644 --- a/src/main/java/pacmanGame/Ghost.java +++ b/src/main/java/pacmanGame/Ghost.java @@ -1,12 +1,21 @@ package pacmanGame; public class Ghost { - public Vector2 position; - public final GameManager gameManager; - - public Ghost(GameManager gameManager) { - this.gameManager = gameManager; - this.position = new Vector2(-1, -1); - } - + public Vector2 position; + public final GameManager gameManager; + public final int ghostNumber; + + 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); + } }