Added Scatter-strategy

This commit is contained in:
Urban Modig
2025-08-19 21:17:36 +02:00
parent 64dcba2584
commit 9f316e5b43
13 changed files with 183 additions and 80 deletions

View File

@ -1,21 +1,21 @@
package se.urmo.game.entities;
import se.urmo.game.map.GameMap;
import se.urmo.game.util.Direction;
import java.awt.Point;
public class PinkyStrategy implements GhostStrategy{
@Override
public Point chooseTarget(PacMan pacman) {
public Point chooseTarget(PacMan pacman, GameMap map) {
Direction pacmanDir = pacman.getDirection();
Point pacmanPos = pacman.getTilePosition();
return switch (pacmanDir){
case RIGHT -> new Point(pacmanPos.x + 4 * 16, pacmanPos.y);
case LEFT -> new Point(pacmanPos.x - 4 * 16, pacmanPos.y);
case DOWN -> new Point(pacmanPos.x, pacmanPos.y + 4 * 16);
case UP -> new Point(pacmanPos.x, pacmanPos.y - 4 * 16);
case RIGHT -> new Point(pacmanPos.x + 4 * GameMap.MAP_TILESIZE, pacmanPos.y);
case LEFT -> new Point(pacmanPos.x - 4 * GameMap.MAP_TILESIZE, pacmanPos.y);
case DOWN -> new Point(pacmanPos.x, pacmanPos.y + 4 * GameMap.MAP_TILESIZE);
case UP -> new Point(pacmanPos.x, pacmanPos.y - 4 * GameMap.MAP_TILESIZE);
case NONE -> pacmanPos;
default -> throw new IllegalStateException("Illegal direction");
};
}
}