Repository navigation
Expand file tree
/
Copy pathBullet.java
More file actions
90 lines (75 loc) · 2.35 KB
/
Copy pathBullet.java
File metadata and controls
90 lines (75 loc) · 2.35 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import java.util.ArrayList;
public class Bullet {
private int speed = 3;
private int power;
private int location_x;
private int location_y;
//this boolean data member determines the type of bullet (nokhod , partabe , yakhi)
private String bulletType;
private boolean isForward;
public Bullet(int location_x, int location_y, String bulletType , boolean isForward , int power) {
this.location_x = location_x;
this.location_y = location_y;
this.bulletType = bulletType;
this.isForward = isForward;
this.power = power;
}
public boolean getIsForward() {
return isForward;
}
public int getSpeed() {
return speed;
}
public int getPower() {
return power;
}
public int getLocation_x() {
return location_x;
}
public int getLocation_y() {
return location_y;
}
public String getBulletType() {
return bulletType;
}
public void setSpeed(int speed) {
this.speed = speed;
}
public void setPower(int power) {
this.power = power;
}
public void setLocation_x(int location_x) {
this.location_x = location_x;
}
public void setLocation_y(int location_y) {
this.location_y = location_y;
}
public void setBulletType(String bulletType) {
this.bulletType = bulletType;
}
public void setForward(boolean forward) {
isForward = forward;
}
public void moveForward(ArrayList<Zombie> zombies){
for (int i = 0 ; i < this.speed ; i++){
if (findZombie(location_x , location_y + 1 , zombies) == null) {
this.setLocation_y(location_y + 1);
}
else
break;
}
}
public void moveBackward(ArrayList<Zombie> zombies){
for (int i = 0 ; i < this.speed ; i++){
if (findZombie(location_x , location_y - 1 , zombies) == null) {
this.setLocation_y(location_y - 1);
}
else
break;
}
}
public Zombie findZombie(int x , int y , ArrayList<Zombie> Zombies){
for (Zombie zombie : Zombies) if (zombie.getLocation_y() == y && zombie.getLocation_x() == x) return zombie;
return null;
}
}