summaryrefslogtreecommitdiff
path: root/src/ch
diff options
context:
space:
mode:
Diffstat (limited to 'src/ch')
-rw-r--r--src/ch/epfl/maze/physical/pacman/Pinky.java35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/ch/epfl/maze/physical/pacman/Pinky.java b/src/ch/epfl/maze/physical/pacman/Pinky.java
index 3e4209d..ebabc15 100644
--- a/src/ch/epfl/maze/physical/pacman/Pinky.java
+++ b/src/ch/epfl/maze/physical/pacman/Pinky.java
@@ -6,31 +6,54 @@ import ch.epfl.maze.physical.GhostPredator;
6import ch.epfl.maze.util.Direction; 6import ch.epfl.maze.util.Direction;
7import ch.epfl.maze.util.Vector2D; 7import ch.epfl.maze.util.Vector2D;
8 8
9import java.util.Vector;
10
9/** 11/**
10 * Pink ghost from the Pac-Man game, targets 4 squares in front of its target. 12 * Pink ghost from the Pac-Man game, targets 4 squares in front of its target.
13 *
14 * @author Pacien TRAN-GIRARD
11 */ 15 */
12
13public class Pinky extends GhostPredator { 16public class Pinky extends GhostPredator {
14 17
18 private static final int TARGET_OFFSET = 4;
15 /** 19 /**
16 * Constructs a Pinky with a starting position. 20 * Constructs a Pinky with a starting position.
17 * 21 *
18 * @param position Starting position of Pinky in the labyrinth 22 * @param position Starting position of Pinky in the labyrinth
19 */ 23 */
20
21 public Pinky(Vector2D position) { 24 public Pinky(Vector2D position) {
22 super(position); 25 super(position);
23 // TODO
24 } 26 }
25 27
28 /**
29 * Targets the position the Prey is heading toward.
30 *
31 * @param daedalus The Daedalus
32 * @return The projected position
33 */
26 @Override 34 @Override
27 public Direction move(Direction[] choices, Daedalus daedalus) { 35 protected Vector2D getPreyTargetPosition(Daedalus daedalus) {
28 // TODO 36 Vector2D offsetVector = this.getTargetOffsetVector(this.getPreyDirection(daedalus));
29 return Direction.NONE; 37 return this
38 .getPreyPosition(daedalus)
39 .add(offsetVector);
40 }
41
42 /**
43 * Returns the offset vector directed to the given Direction.
44 *
45 * @param direction The Direction
46 * @return The offset Vector2D
47 */
48 private Vector2D getTargetOffsetVector(Direction direction) {
49 return (new Vector2D())
50 .addDirectionTo(direction)
51 .mul(TARGET_OFFSET);
30 } 52 }
31 53
32 @Override 54 @Override
33 public Animal copy() { 55 public Animal copy() {
34 return new Pinky(this.getPosition()); 56 return new Pinky(this.getPosition());
35 } 57 }
58
36} 59}