Added mode-management and second ghost
This commit is contained in:
21
src/main/java/se/urmo/game/entities/PinkyStrategy.java
Normal file
21
src/main/java/se/urmo/game/entities/PinkyStrategy.java
Normal 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");
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user