-
Notifications
You must be signed in to change notification settings - Fork 1
/
VictoryScreen.java
94 lines (82 loc) · 2.53 KB
/
VictoryScreen.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
package FightKnights.Logic;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
/**
*
* @author alex1
*/
public class VictoryScreen extends BasicGameState
{
private Image fondo1, fondo2;
private Image botonSalir, botonSonido, botonReset;
private Input raton;
private Music musica;
private boolean gana, ratonPress, reinicioOver, salirOver;
private Match match;
private int h1;
public VictoryScreen() throws SlickException
{
}
@Override
public int getID()
{
return 2;
}
@Override
public void init(GameContainer container, StateBasedGame game) throws SlickException
{
match = Match.getMatchInstance();
fondo1 = new Image("res/victoria1.png");
fondo2 = new Image("res/victoria2.png");
botonSalir = new Image("res/salir.png");
botonReset = new Image ("res/reiniciar.png");
raton = container.getInput();
}
@Override
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException
{
if(gana){
fondo1.draw();
}else{
fondo2.draw();
}
g.drawImage(botonReset, 380, 435);
g.drawImage(botonSalir, 700, 435);
}
@Override
public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException
{
h1 = match.getP_turn();
gana = h1==1;
ratonPress = raton.isMousePressed(Input.MOUSE_LEFT_BUTTON);
ratonSobreBoton();
botonPulsado(game);
}
public void ratonSobreBoton()
{
reinicioOver = ((raton.getMouseX()>=380&&raton.getMouseY()>=435)&&(raton.getMouseX()<=580&&raton.getMouseY()<=485));
salirOver = ((raton.getMouseX()>=700&&raton.getMouseY()>=435)&&(raton.getMouseX()<=900&&raton.getMouseY()<=485));
}
public void botonPulsado(StateBasedGame game) throws SlickException
{
if(ratonPress)
{
if(reinicioOver)
{
game.enterState(1);
match.setReinicio(true);
}
//Cierra el juego
if(salirOver)
{
System.exit(0);
}
}
}
}