-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHorizontalGhost.java
More file actions
35 lines (28 loc) · 1.32 KB
/
HorizontalGhost.java
File metadata and controls
35 lines (28 loc) · 1.32 KB
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
//Kaan Cinar && Bogachan Arslan && Onder Soydal && Sinan Karabocuoglu
//HorizontalGhost
//24.04.2018
import java.awt.*;
import java.util.ArrayList;
public class HorizontalGhost extends Ghost {
public HorizontalGhost(int initialX, int initialY, int vel, int squareSize, int width, Shape[][] grid) {
super(initialX, initialY, vel, squareSize,width, grid);
COLOR=Color.PINK;
timeToScatter=6;
}
@Override
public ArrayList<Character> determineDirectionOrder(int pacmanX, int pacmanY,char pacmanDirection){
int[] direction={pacmanX-xPos,pacmanY-yPos};
ArrayList<Character> directions=new ArrayList<Character>();
if(direction[0]==0 && direction[1]==0){
directions.add('W');directions.add('E');directions.add('S');directions.add('N');
} else {
if (direction[0] > 0) { directions.add('E');directions.add('W'); }
else if (direction[0] < 0) { directions.add('W');directions.add('E'); }
if (direction[1] > 0) { directions.add('S');directions.add('N'); }
else if (direction[1] < 0) { directions.add('N');directions.add('S'); }
if(direction[0]==0) { directions.add('E'); directions.add('W'); }
if(direction[1]==0) { directions.add('N'); directions.add('S'); }
}
return directions;
}
}