-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathBombTank.java
More file actions
55 lines (49 loc) · 1.46 KB
/
BombTank.java
File metadata and controls
55 lines (49 loc) · 1.46 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
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
public class BombTank {
private int x, y;
private boolean live = true;
private TankClient tc;
private static Toolkit tk = Toolkit.getDefaultToolkit();
private static Image[] imgs = {
tk.getImage(BombTank.class.getClassLoader().getResource(
"images/1.gif")),
tk.getImage(BombTank.class.getClassLoader().getResource(
"images/2.gif")),
tk.getImage(BombTank.class.getClassLoader().getResource(
"images/3.gif")),
tk.getImage(BombTank.class.getClassLoader().getResource(
"images/4.gif")),
tk.getImage(BombTank.class.getClassLoader().getResource(
"images/5.gif")),
tk.getImage(BombTank.class.getClassLoader().getResource(
"images/6.gif")),
tk.getImage(BombTank.class.getClassLoader().getResource(
"images/7.gif")),
tk.getImage(BombTank.class.getClassLoader().getResource(
"images/8.gif")),
tk.getImage(BombTank.class.getClassLoader().getResource(
"images/9.gif")),
tk.getImage(BombTank.class.getClassLoader().getResource(
"images/10.gif")), };
int step = 0;
public BombTank(int x, int y, TankClient tc) {
this.x = x;
this.y = y;
this.tc = tc;
}
public void draw(Graphics g) {
if (!live) {
tc.bombTanks.remove(this);
return;
}
if (step == imgs.length) {
live = false;
step = 0;
return;
}
g.drawImage(imgs[step], x, y, null);
step++;
}
}