Ghost movement working - first rev

This commit is contained in:
Urban Modig
2025-08-17 15:03:54 +02:00
parent 1bbba216d2
commit 05285529c5
10 changed files with 95 additions and 63 deletions

View File

@ -1,7 +1,9 @@
package se.urmo.game.state;
import lombok.Getter;
import se.urmo.game.collision.CollisionChecker;
import se.urmo.game.collision.GhostCollisionChecker;
import se.urmo.game.entities.BlinkyStrategy;
import se.urmo.game.entities.Ghost;
import se.urmo.game.entities.PacMan;
import se.urmo.game.main.Game;
@ -16,19 +18,20 @@ public class PlayingState implements GameState {
private final GameStateManager gameStateManager;
private final Ghost ghost;
private PacMan pacman;
@Getter
private GameMap map;
public PlayingState(Game game, GameStateManager gameStateManager) {
this.game = game;
this.gameStateManager = gameStateManager;
this.map = new GameMap();
this.pacman = new PacMan(game, new CollisionChecker(map));
this.ghost = new Ghost(game, new GhostCollisionChecker(map), null);
this.ghost = new Ghost(game, new GhostCollisionChecker(map), new BlinkyStrategy());
}
@Override
public void update() {
pacman.update();
ghost.update();
ghost.update(pacman);
}
@Override
@ -58,8 +61,4 @@ public class PlayingState implements GameState {
pacman.setMoving(false);
pacman.setDirection(Direction.NONE);
}
public GameMap getMap() {
return map;
}
}