-
Notifications
You must be signed in to change notification settings - Fork 0
/
Home.java
110 lines (84 loc) · 3.76 KB
/
Home.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
import java.awt.*;
import java.io.File;
import javax.swing.*;
public class Home extends JPanel {
private Font Fonte;
public static Pokemon pokemonSelecionado;
public Home(Game frame) {
editar(frame);
}
private void editar(Game frame) {
Fonte = DefinirFonte.fonte();
setLayout(new BorderLayout());
JPanel homePanel = new JPanel();
homePanel.setLayout(new BorderLayout());
JLabel backgroundLabel = new JLabel();
backgroundLabel.setIcon(new ImageIcon("assets/backgroundImages/focusPage.png"));
backgroundLabel.setBounds(0, 0, 960, 640);
setPokemons(backgroundLabel);
setPersonagemJogador(backgroundLabel);
JLabel titleLabel = new JLabel("Vamos Batalhar!");
titleLabel.setFont(Fonte.deriveFont(Font.PLAIN, 60));
titleLabel.setForeground(Color.WHITE);
titleLabel.setBounds(650, 450, 800, 50);
JButton nextButton = new JButton("Iniciar Batalha");
nextButton.setFont(Fonte.deriveFont(Font.PLAIN, 40));
nextButton.addActionListener(e -> {
PokemonsBatle pokemonsBatle = new PokemonsBatle(frame);
pokemonsBatle.atualizarVidaPlayer();
pokemonsBatle.atualizarVidaInimigo();
pokemonsBatle.repaint();
frame.mudarTela(pokemonsBatle);
});
nextButton.setBounds(650, 500, 300, 70);
JLabel sairTitleLabel = new JLabel("Salvar e sair");
sairTitleLabel.setFont(Fonte.deriveFont(Font.PLAIN, 60));
sairTitleLabel.setForeground(Color.WHITE);
sairTitleLabel.setBounds(50, 450, 800, 50);
JButton sairButton = new JButton("SAIR");
sairButton.setFont(Fonte.deriveFont(Font.PLAIN, 40));
sairButton.addActionListener(e -> {
Player.salvarDados();
System.exit(0);
});
sairButton.setBounds(50, 500, 300, 70);
JButton apagarButton = new JButton("Apagar Save");
apagarButton.setFont(Fonte.deriveFont(Font.PLAIN, 20));
apagarButton.addActionListener(e -> {
File file = new File("player_data.dat");
if (file.exists()) {
file.delete();
}
System.exit(0);
});
apagarButton.setBounds(10, 10, 120, 50);
backgroundLabel.add(apagarButton);
backgroundLabel.add(titleLabel);
backgroundLabel.add(nextButton);
backgroundLabel.add(sairTitleLabel);
backgroundLabel.add(sairButton);
add(backgroundLabel, BorderLayout.NORTH);
}
private void setPokemons(JLabel backgroundLabel) {
pokemonSelecionado = new Pokemon(Player.pokemonNome , "front");
JLabel pokemon = pokemonSelecionado.getImagemLabel();
pokemon.setBounds( 270 , 230 , 300, 300);
backgroundLabel.add(pokemon);
}
private void setPersonagemJogador(JLabel backgroundLabel) {
JLabel Personagem= new JLabel();
Personagem.setFocusable(true);
Personagem.setBounds( 400 , -50 , 960, 640);
JLabel nomePersonagem = new JLabel(Player.nome);
nomePersonagem.setFont(Fonte.deriveFont(Font.PLAIN, 40));
nomePersonagem.setForeground(Color.BLACK);
nomePersonagem.setBounds( 560 , 150 , 200, 50);
backgroundLabel.add(nomePersonagem);
if (Player.tipoPersonagem.equals("boy")) {
Personagem.setIcon(new ImageIcon("assets/personagens/ash.png"));
} else if (Player.tipoPersonagem.equals("girl")){
Personagem.setIcon(new ImageIcon("assets/personagens/girl.png"));
}
backgroundLabel.add(Personagem);
}
}