-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBullet.java
70 lines (65 loc) · 1.07 KB
/
Bullet.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
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
import java.awt.*;
import javax.swing.*;
import java.util.*;
class Bullet //implements Runnable
{
int x,y,bx,by;
boolean alive;
LinkedList<Bomb> Neut;
public Bullet(int x,int y,LinkedList<Bomb> Neut)
{
this.x=x;
this.y=y;
alive=true;
this.Neut=Neut;
}
void inc()
{
y=y-5;
for(int i=0;i<Neut.size();i++)
{
Bomb p=Neut.get(i);
if(p.alive)
{
bx=p.x;
by=p.y;
if(x>=bx && x<=bx+25 && y<=by+10)
{
System.out.println("blaaast");
alive=false;
p.alive=false;
p.speed=0;
return;
}
}
}
if(y<0)
alive=false;
}
void drawbullet(Graphics g)
{
if(!alive)
return;
g.setColor(Color.white);
g.fillRect(x,y,3,6);
}
}
/**public void run()
{
y--;
//System.out.println(y);
p.repaint() ;
if(y<0)
{
alive=false;
return;
}
try
{
Thread.sleep(1000);
}
catch(Exception e)
{
e.printStackTrace();
}
}*/