-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathHome.java
More file actions
73 lines (59 loc) · 1.45 KB
/
Home.java
File metadata and controls
73 lines (59 loc) · 1.45 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
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Toolkit;
public class Home {
private int x, y;
private TankClient tc;
public static final int width = 43, length = 43;
private boolean live = true;
private static Toolkit tk = Toolkit.getDefaultToolkit();
private static Image[] homeImags = null;
static {
homeImags = new Image[] { tk.getImage(CommonWall.class
.getResource("Images/home.jpg")), };
}
public Home(int x, int y, TankClient tc) {
this.x = x;
this.y = y;
this.tc = tc;
}
public void gameOver(Graphics g) {
tc.tanks.clear();
tc.metalWall.clear();
tc.otherWall.clear();
tc.bombTanks.clear();
tc.theRiver.clear();
tc.trees.clear();
tc.bullets.clear();
tc.homeTank.setLive(false);
Color c = g.getColor();
g.setColor(Color.green);
Font f = g.getFont();
g.setFont(new Font(" ", Font.PLAIN, 40));
g.setFont(f);
g.setColor(c);
}
public void draw(Graphics g) {
if (live) {
g.drawImage(homeImags[0], x, y, null);
for (int i = 0; i < tc.homeWall.size(); i++) {
CommonWall w = tc.homeWall.get(i);
w.draw(g);
}
} else {
gameOver(g);
}
}
public boolean isLive() {
return live;
}
public void setLive(boolean live) {
this.live = live;
}
public Rectangle getRect() {
return new Rectangle(x, y, width, length);
}
}