Class ChasePatrol
java.lang.Object
edu.uoc.pacman.model.entities.characters.ghosts.chase.ChasePatrol
- All Implemented Interfaces:
ChaseBehaviour
It implements the
In order to locate Inky's target position, we first start by selecting the position
ChaseBehaviour
interface according to an aggressive behaviour.In order to locate Inky's target position, we first start by selecting the position
TILES_OFFSET
tiles in front of Pac-Man in his current
direction of travel, similar to Pinky's targeting method.
From there, imagine drawing a vector from Blinky's position
to this tile, and then doubling (i.e. the value of VECTOR_INCREASE
the length of the vector.
The tile that this new, extended vector ends on will be Inky's actual target.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
The amount of tiles/cells/positions/steps that must be added to the Pacman's position.private static final int
The amount which the vector equals to targetPositionBlinky - FIRST_BLINKY_POSITION must be extended (multiplied). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetChasePosition
(Ghost ghost) The ghost will chase twice a vector equals to:
-
Field Details
-
TILES_OFFSET
private static final int TILES_OFFSETThe amount of tiles/cells/positions/steps that must be added to the Pacman's position.- See Also:
-
VECTOR_INCREASE
private static final int VECTOR_INCREASEThe amount which the vector equals to targetPositionBlinky - FIRST_BLINKY_POSITION must be extended (multiplied).- See Also:
-
-
Constructor Details
-
ChasePatrol
public ChasePatrol()
-
-
Method Details
-
getChasePosition
The ghost will chase twice a vector equals to:
targetBlinkyPosition - FIRST_BLINKY_POSITION targetBlinkyPosition is the position which is
TILES_OFFSET
steps/tiles/cells/positions ahead of Pacman's position in the direction Pacman is facing.- Specified by:
getChasePosition
in interfaceChaseBehaviour
- Parameters:
ghost
- Ghost object that chases.- Returns:
- Position where the ghost must go:
VECTOR_INCREASE * (targetBlinkyPosition - FIRST_BLINKY_POSITION)
If there are no Blinky ghosts, then it returns targetBlinkyPosition.
- Since:
- getChasePosition in interface
ChaseBehaviour
.
-