-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExplode.java
More file actions
55 lines (46 loc) · 959 Bytes
/
Copy pathExplode.java
File metadata and controls
55 lines (46 loc) · 959 Bytes
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
import java.awt.Color;
import java.awt.Graphics;
/**
* 代表爆炸的类
* 使用大小不一的圆进行模拟
* @author kanshanlei
*
*/
public class Explode {
int x, y;
private int[] diameters = { 4, 7, 12, 18, 26, 32, 49, 30, 14, 6 };
private boolean live = true;
private TankClient tc;
int step = 0;
/**
* 根据位置产生新的爆炸
* @param x 爆炸点的x坐标
* @param y 爆炸点的y坐标
* @param tc 爆炸所产生的场所
* @see TankClient
*/
public Explode(int x, int y, TankClient tc) {
this.x = x;
this.y = y;
this.tc = tc;
}
/**
* 画出爆炸当前的圆
* @param g 画笔
* @see java.awt.Graphics
*/
public void draw(Graphics g) {
if (!live) {
tc.explodes.remove(this);
return;
}
Color c = g.getColor();
g.setColor(Color.ORANGE);
g.fillOval(x, y, diameters[step], diameters[step]);
g.setColor(c);
step++;
if (step == diameters.length) {
live = false;
}
}
}