-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPea.java
41 lines (35 loc) · 1.15 KB
/
Pea.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
import javax.swing.*;
import java.awt.*;
public class Pea {
public int posX;
protected GamePanel gp;
public int myLane;
public Pea(GamePanel parent,int lane,int startX){
this.gp = parent;
this.myLane = lane;
posX = startX;
}
public void advance(){
Rectangle pRect = new Rectangle(posX,130+myLane*120,28,28);
for (int i = 0; i < gp.laneZombies.get(myLane).size(); i++) {
Zombie z = gp.laneZombies.get(myLane).get(i);
Rectangle zRect = new Rectangle(z.posX,109 + myLane*120,400,120);
if(pRect.intersects(zRect)){
z.health -= 300;
boolean exit = false;
if(z.health < 0){
System.out.println("ZOMBIE DIE");
gp.laneZombies.get(myLane).remove(i);
GamePanel.setProgress(10);
exit = true;
}
gp.lanePeas.get(myLane).remove(this);
if(exit) break;
}
}
/*if(posX > 2000){
gp.lanePeas.get(myLane).remove(this);
}*/
posX += 15;
}
}