java.lang.Object
edu.uoc.pacman.model.entities.characters.ghosts.chase.ChasePatrol
All Implemented Interfaces:
ChaseBehaviour

public class ChasePatrol extends Object implements ChaseBehaviour
It implements the 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

    Fields
    Modifier and Type
    Field
    Description
    private 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    The ghost will chase twice a vector equals to:

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • TILES_OFFSET

      private static final int TILES_OFFSET
      The amount of tiles/cells/positions/steps that must be added to the Pacman's position.
      See Also:
    • VECTOR_INCREASE

      private static final int VECTOR_INCREASE
      The amount which the vector equals to targetPositionBlinky - FIRST_BLINKY_POSITION must be extended (multiplied).
      See Also:
  • Constructor Details

    • ChasePatrol

      public ChasePatrol()
  • Method Details

    • getChasePosition

      public Position getChasePosition(Ghost ghost)
      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 interface ChaseBehaviour
      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.