-
Notifications
You must be signed in to change notification settings - Fork 0
/
Footer.java
148 lines (133 loc) · 6.82 KB
/
Footer.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
public class Footer extends JPanel {
public String image;
public Footer() {
initFooter();
}
public void initFooter() {
// setBackground(Color.red);
setFocusable(true);
setSize(TankGame.getGameWidth(), (int) (TankGame.getGameHeight() * 0.15));
setPreferredSize(new Dimension(TankGame.getGameWidth(), (int) (TankGame.getGameHeight() * 0.15)));
repaint();
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2D;
g2D = (Graphics2D) g.create();
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// // Draw background image:
ImageIcon imageBackground = new ImageIcon("Resources/footer_background.png");
Image sciimageBackground = imageBackground.getImage();
Graphics2D gpScreenimage = (Graphics2D) g.create();
gpScreenimage.drawImage(sciimageBackground, 0, 0, this);
gpScreenimage.dispose();
// Draw rewards:
// TRIPLE SHOT:
Graphics2D gph3shot = (Graphics2D) g.create();
if (Board.MainTank.getTriple_Shot()) {
ImageIcon imageicon = new ImageIcon("Resources/reward_3shot.png");
Image image = imageicon.getImage();
// image = image.getScaledInstance((int) (TankGame.getGameHeight() * 0.15),
// (int) (TankGame.getGameHeight() * 0.15),
// java.awt.Image.SCALE_SMOOTH);
gph3shot.drawImage(image, TankGame.getGameWidth() - (int) (this.getHeight() * 0.15),
TankGame.getGameHeight(), (int) (this.getHeight() * 0.08),
(int) (this.getHeight() * 0.08), this);
} else {
ImageIcon imageicon = new ImageIcon("Resources/reward_3shot_border.png");
Image image = imageicon.getImage();
// image = image.getScaledInstance((int) (TankGame.getGameHeight() * 0.15),
// (int) (TankGame.getGameHeight() * 0.15),
// java.awt.Image.SCALE_SMOOTH);
gph3shot.drawImage(image, TankGame.getGameWidth() - (int) (this.getHeight() * 0.15),
TankGame.getGameHeight(), (int) (this.getHeight() * 0.08),
(int) (this.getHeight() * 0.08), this);
}
gph3shot.dispose();
// ENERGY:
Graphics2D gphenergy = (Graphics2D) g.create();
if (Board.MainTank.getDouble_speed()) {
ImageIcon imageicon = new ImageIcon("Resources/reward_energy.png");
Image image = imageicon.getImage();
// image = image.getScaledInstance((int) (TankGame.getGameHeight() * 0.15),
// (int) (TankGame.getGameHeight() * 0.15),
// java.awt.Image.SCALE_SMOOTH);
gphenergy.drawImage(image, TankGame.getGameWidth() - 2 * (int) (this.getHeight() * 0.15),
TankGame.getGameHeight(), (int) (this.getHeight() * 0.08),
(int) (this.getHeight() * 0.08), this);
} else {
ImageIcon imageicon = new ImageIcon("Resources/reward_energy_border.png");
Image image = imageicon.getImage();
// image = image.getScaledInstance((int) (TankGame.getGameHeight() * 0.15),
// (int) (TankGame.getGameHeight() * 0.15),
// java.awt.Image.SCALE_SMOOTH);
gphenergy.drawImage(image, TankGame.getGameWidth() - 2 * (int) (this.getHeight() * 0.15),
TankGame.getGameHeight(), (int) (this.getHeight() * 0.08),
(int) (this.getHeight() * 0.08), this);
}
gphenergy.dispose();
// GHOST:
Graphics2D gphghost = (Graphics2D) g.create();
if (Board.MainTank.getGhost()) {
ImageIcon imageicon = new ImageIcon("Resources/reward_ghost.png");
Image image = imageicon.getImage();
// image = image.getScaledInstance((int) (TankGame.getGameHeight() * 0.15),
// (int) (TankGame.getGameHeight() * 0.15),
// java.awt.Image.SCALE_SMOOTH);
gphghost.drawImage(image, TankGame.getGameWidth() - 3 * (int) (this.getHeight() * 0.15),
TankGame.getGameHeight(), (int) (this.getHeight() * 0.08),
(int) (this.getHeight() * 0.08), this);
} else {
ImageIcon imageicon = new ImageIcon("Resources/reward_ghost_border.png");
Image image = imageicon.getImage();
// image = image.getScaledInstance((int) (TankGame.getGameHeight() * 0.15),
// (int) (TankGame.getGameHeight() * 0.15),
// java.awt.Image.SCALE_SMOOTH);
gphghost.drawImage(image, TankGame.getGameWidth() - 3 * (int) (this.getHeight() * 0.15),
TankGame.getGameHeight(), (int) (this.getHeight() * 0.08),
(int) (this.getHeight() * 0.08), this);
}
gphghost.dispose();
// SHIELD:
Graphics2D gphshield = (Graphics2D) g.create();
if (Board.MainTank.getShield()) {
ImageIcon imageicon = new ImageIcon("Resources/reward_shield.png");
Image image = imageicon.getImage();
// image = image.getScaledInstance((int) (TankGame.getGameHeight() * 0.15),
// (int) (TankGame.getGameHeight() * 0.15),
// java.awt.Image.SCALE_SMOOTH);
gphshield.drawImage(image, TankGame.getGameWidth() - 4 * (int) (this.getHeight() * 0.15),
TankGame.getGameHeight(), (int) (this.getHeight() * 0.08),
(int) (this.getHeight() * 0.08), this);
} else {
ImageIcon imageicon = new ImageIcon("Resources/reward_shield_border.png");
Image image = imageicon.getImage();
// image = image.getScaledInstance((int) (TankGame.getGameHeight() * 0.15),
// (int) (TankGame.getGameHeight() * 0.15),
// java.awt.Image.SCALE_SMOOTH);
gphshield.drawImage(image, TankGame.getGameWidth() - 4 * (int) (this.getHeight() * 0.15),
TankGame.getGameHeight(), (int) (this.getHeight() * 0.08),
(int) (this.getHeight() * 0.08), this);
}
gphshield.dispose();
// Draw lives:
for (int i = 0; i < Board.MainTank.getLives(); i++) {
Graphics2D gphlive = (Graphics2D) g.create();
ImageIcon imageicon = new ImageIcon("Resources/reward_1up.png");
Image image = imageicon.getImage();
gphlive.drawImage(image, i * (int) (this.getHeight() * 0.15),
TankGame.getGameHeight(),
(int) (this.getHeight() * 0.08),
(int) (this.getHeight() * 0.08), this);
gphlive.dispose();
}
}
}