22 lines
816 B
Java
22 lines
816 B
Java
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(Ghost ghost, PacMan pacman, GameMap map) {
|
|
Direction pacmanDir = pacman.getDirection();
|
|
Point pacmanPos = pacman.getTilePosition();
|
|
return switch (pacmanDir){
|
|
case RIGHT -> new Point(pacmanPos.x + 8 * GameMap.MAP_TILESIZE, pacmanPos.y);
|
|
case LEFT -> new Point(pacmanPos.x - 8 * GameMap.MAP_TILESIZE, pacmanPos.y);
|
|
case DOWN -> new Point(pacmanPos.x, pacmanPos.y + 8 * GameMap.MAP_TILESIZE);
|
|
case UP -> new Point(pacmanPos.x, pacmanPos.y - 8 * GameMap.MAP_TILESIZE);
|
|
case NONE -> pacmanPos;
|
|
};
|
|
}
|
|
}
|