Added mode-management and second ghost

This commit is contained in:
Urban Modig
2025-08-17 22:10:10 +02:00
parent a2b9b2264e
commit 9d06b038e0
8 changed files with 125 additions and 40 deletions

View File

@ -0,0 +1,21 @@
package se.urmo.game.entities;
import se.urmo.game.util.Direction;
import java.awt.Point;
public class PinkyStrategy implements GhostStrategy{
@Override
public Point chooseTarget(PacMan pacman) {
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 NONE -> pacmanPos;
default -> throw new IllegalStateException("Illegal direction");
};
}
}