-
Notifications
You must be signed in to change notification settings - Fork 0
/
Clyde.java
43 lines (36 loc) · 1.1 KB
/
Clyde.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package PacmanPack;
public class Clyde extends Ghost {
public Clyde(Cell cell, int spriteLevel) {
super(cell, spriteLevel);
spriteBaseSpeed = 0.1;
spriteSpeed = spriteBaseSpeed;
homeCell1 = Pacman.field[29][8];
homeCell2 = Pacman.field[25][7];
homeCell = homeCell1;
ghostHouse = cell;
danceStance = 7;
loadNormalDanceStances();
startAnimation(normalDanceAnimation[0]);
}
@Override
protected Cell scatterStrategy() {
return homeCell;
}
@Override
protected Cell chaseStrategy() {
return clydeChaseStrategy();
}
private Cell clydeChaseStrategy() {
Cell targetCell;
targetCell = Pacman.pacman.getCell();
if (distToPacman() <= 8.0) {
targetCell = homeCell;
}
return targetCell;
}
private double distToPacman() {
int dCol = Math.abs(Pacman.pacman.getCell().getCol() - spriteCell.getCol());
int dRow = Math.abs(Pacman.pacman.getCell().getRow() - spriteCell.getRow());
return Math.hypot(dRow, dCol);
}
}