-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVerticalGhost.java
More file actions
33 lines (28 loc) · 1.27 KB
/
VerticalGhost.java
File metadata and controls
33 lines (28 loc) · 1.27 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
//Kaan Cinar && Bogachan Arslan && Onder Soydal && Sinan Karabocuoglu
//VerticalGhost
//24.04.2018
import java.awt.*;
import java.util.ArrayList;
public class VerticalGhost extends Ghost {
public VerticalGhost(int x, int y,int vel, int size,int width, Shape[][] grid){
super(x,y,vel,size,width,grid);
COLOR=Color.RED;
timeToScatter=7;
}
@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('N');directions.add('S');directions.add('E');directions.add('W');
} else {
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'); }
else if (direction[0] < 0) { directions.add('W');directions.add('E'); }
if(direction[0]==0) { directions.add('E'); directions.add('W'); }
if(direction[1]==0) { directions.add('N'); directions.add('S'); }
}
return directions;
}
}