-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWall.java
63 lines (49 loc) · 1.4 KB
/
Wall.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
import java.awt.Image;
import javax.swing.ImageIcon;
public class Wall {
private int posx;
private int posy;
private String type;
private boolean visible;
private Image image;
public Wall(int posx, int posy, String type) {
this.posx = posx;
this.posy = posy;
this.type = type;
this.visible = true;
loadImage(type);
}
public int getPosx() {
return posx;
}
public int getPosy() {
return posy;
}
public void setPosx(int posx) {
this.posx = posx;
}
public void setPosy(int posy) {
this.posy = posy;
}
public Image getImage() {
return this.image;
}
public String getType() {
return type;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
public boolean getVisible() {
return visible;
}
private void loadImage(String type) {
if (type.startsWith("reward")) {
type = "reward";
}
ImageIcon imageIcon = new ImageIcon("Resources/wall_" + type + ".png"); // load the image to a imageIcon
Image scimage = imageIcon.getImage(); // transform it
this.image = scimage.getScaledInstance((int) TankGame.getImgSizeWall(), (int) TankGame.getImgSizeWall(),
java.awt.Image.SCALE_SMOOTH);
}
}