-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPokemonsBatle.java
More file actions
151 lines (117 loc) · 5.64 KB
/
PokemonsBatle.java
File metadata and controls
151 lines (117 loc) · 5.64 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
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
149
150
151
import javax.swing.*;
import java.awt.*;
public class PokemonsBatle extends JPanel {
private InterfaceCaixa interface1;
public static PokemonsBatle instance;
private Font Fonte = DefinirFonte.fonte();
private JLabel label = new JLabel();
private JLabel inimigoInfo = new JLabel();
private JLabel inimigoName = new JLabel();
private JLabel inimigoHP = new JLabel();
private JLabel inimigoLabelLv = new JLabel();
private JLabel playerInfo = new JLabel();
private JLabel playerName = new JLabel();
private JLabel playerHP = new JLabel();
private JLabel playerLabelLv = new JLabel();
public static int playerHPValue = 192;
public static int inimigoHPValue = 192;
public static int playerLv = 1;
public static int inimigoLv = 1;
public PokemonsBatle(Game frame){
instance = this;
setBattleCardLayout(frame);
}
public void setBattleCardLayout(Game frame) {
setLayout(new BorderLayout());
label.setIcon(new ImageIcon("assets/backgroundImages/Battle Background.png"));
interface1 = new InterfaceCaixa(frame);
Enemy.inimigoAtual.getImagemLabel().setBounds(580, 40, 256, 256);
Player.pokemonSelecionado.getImagemLabel().setBounds(120, Player.getAlturaPokemon(), 256, 256);
inimigoInfo.setIcon(new ImageIcon("assets/battleElements/inimigo hp.png"));
inimigoInfo.setBounds(50, 30, 400, 116);
inimigoName.setText(Enemy.inimigoAtual.getNome().toUpperCase());
inimigoName.setFont(Fonte.deriveFont(Font.PLAIN,50f));
inimigoName.setBounds(25, 10, 320, 45);
inimigoHP.setBackground(new Color(34, 139, 34));
inimigoHP.setOpaque(true);
inimigoHP.setBounds(156, 68, inimigoHPValue, 12); // o tamanho max do ahp é 192
inimigoLabelLv.setText(Integer.toString(inimigoLv));
inimigoLabelLv.setFont(Fonte.deriveFont(Font.PLAIN,50f));
inimigoLabelLv.setBounds(327, 10, 100, 45);
inimigoInfo.add(inimigoLabelLv);
inimigoInfo.add(inimigoHP);
inimigoInfo.add(inimigoName);
label.add(inimigoInfo);
playerInfo.setIcon(new ImageIcon("assets/battleElements/player hp.png"));
playerInfo.setBounds(505, 295, 416, 148);
playerName.setText(Player.pokemonSelecionado.getNome().toUpperCase());
playerName.setFont(Fonte.deriveFont(Font.PLAIN,50f));
playerName.setBounds(60, 10, 320, 45);
playerHP.setBackground(new Color(34, 139, 34));
playerHP.setOpaque(true);
playerHP.setBounds(192, 68, playerHPValue, 12); // o tamanho max do hp é 192
playerLabelLv.setText(Integer.toString(playerLv));
playerLabelLv.setFont(Fonte.deriveFont(Font.PLAIN,50f));
playerLabelLv.setBounds(363, 10, 100, 45);
playerInfo.add(playerLabelLv);
playerInfo.add(playerHP);
playerInfo.add(playerName);
label.add(playerInfo);
label.add(Enemy.inimigoAtual.getImagemLabel());
label.add(Player.pokemonSelecionado.getImagemLabel());
add(label, BorderLayout.NORTH);
add(interface1, BorderLayout.CENTER);
}
public void atualizarVidaPlayer() {
double porcentagemVida = (double) Player.pokemonSelecionado.getVida() / Player.pokemonSelecionado.getVidaMaxima();
if (porcentagemVida <= 0.25) {
playerHP.setBackground(new Color(220, 20, 60)); // Vermelho
} else if (porcentagemVida <= 0.50) {
playerHP.setBackground(new Color(255, 223, 0)); // Amarelo
} else {
playerHP.setBackground(new Color(34, 139, 34)); // Verde
}
playerHPValue = (int) (porcentagemVida * 192);
playerHP.setBounds(192, 68, playerHPValue, 12);
revalidate();
repaint();
}
public void atualizarVidaInimigo() {
double porcentagemVida = (double) Enemy.inimigoAtual.getVida() / Enemy.inimigoAtual.getVidaMaxima();
if (porcentagemVida <= 0.25) {
inimigoHP.setBackground(new Color(220, 20, 60)); // Vermelho
} else if (porcentagemVida <= 0.50) {
inimigoHP.setBackground(new Color(255, 223, 0)); // Amarelo
} else {
inimigoHP.setBackground(new Color(34, 139, 34)); // Verde
}
inimigoHPValue = (int) (porcentagemVida * 192);
inimigoHP.setBounds(156, 68, inimigoHPValue, 12);
revalidate();
repaint();
}
public void atualizarInimigo() {
label.removeAll();
playerLv++;
inimigoLv++;
Enemy.inimigoAtual.getImagemLabel().setBounds(580, 40, 256, 256);
inimigoName.setText(Enemy.inimigoAtual.getNome().toUpperCase());
inimigoName.setFont(Fonte.deriveFont(Font.PLAIN,50f));
inimigoName.setBounds(25, 13, 320, 40);
inimigoInfo.add(inimigoName);
inimigoHPValue = 192;
label.add(inimigoInfo);
Player.pokemonSelecionado.getImagemLabel().setBounds(120, Player.getAlturaPokemon(), 256, 256);
playerName.setText(Player.pokemonSelecionado.getNome().toUpperCase());
playerName.setFont(Fonte.deriveFont(Font.PLAIN,50f));
playerName.setBounds(60, 13, 320, 40);
playerInfo.add(playerName);
label.add(playerInfo);
inimigoLabelLv.setText(Integer.toString(inimigoLv));
playerLabelLv.setText(Integer.toString(playerLv));
label.add(Enemy.inimigoAtual.getImagemLabel());
label.add(Player.pokemonSelecionado.getImagemLabel());
revalidate();
repaint();
}
}