Files
PacMan/src/main/java/se/urmo/game/entities/ClydeStrategy.java
Urban Modig b9a43be3c6 Basic score count working
update takes movement into account
2025-08-22 11:00:19 +02:00

22 lines
625 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package se.urmo.game.entities;
import se.urmo.game.map.GameMap;
import java.awt.Point;
public class ClydeStrategy implements GhostStrategy {
@Override
public Point chooseTarget(Ghost clyde, PacMan pacman, GameMap map) {
Point pacTile = pacman.getPosition();
Point clydeTile = clyde.getPosition(); // ghosts current tile
double distance = pacTile.distance(clydeTile);
if (distance > 8) {
return pacTile; // chase Pac-Man
} else {
return new Point(0, GameMap.OFFSET_Y + (map.rows() * GameMap.MAP_TILESIZE)); // retreat to corner
}
}
}