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
| package LGP;
import org.lwjgl.input.Mouse;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
public class Menu extends BasicGameState{
Image startGris, startRouge, helpGris, helpRouge, exitGris, exitRouge, background, start, exit, help;
public Menu(int state){
}
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
background = new Image("images/blood.png");
startGris = new Image("images/startGris.png");
startRouge = new Image("images/startRouge.png");
helpGris = new Image("images/helpGris.png");
helpRouge = new Image("images/helpRouge.png");
exitGris = new Image("images/exitGris.png");
exitRouge = new Image("images/exitRouge.png");
start = startGris;
help = helpGris;
exit = exitGris;
}
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
background.draw(gc.getWidth()/2 - background.getWidth()/2, 0);
start.draw(100, 100);
help.draw(100, 200);
exit.draw(100, 300);
}
public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
int Xpos = Mouse.getX();
int Ypos = Mouse.getY();
if(Xpos > 140 && Xpos < 240 && Ypos > 940 && Ypos < 970){
start = startRouge;
if (Mouse.isButtonDown(0)){sbg.enterState(2);}
}else{start = startGris;}
if(Xpos > 140 && Xpos < 240 && Ypos > 840 && Ypos < 870){
help = helpRouge;
if (Mouse.isButtonDown(0)){sbg.enterState(1);}
}else{help = helpGris;}
if(Xpos > 140 && Xpos < 240 && Ypos > 740 && Ypos < 770){
exit = exitRouge;
if (Mouse.isButtonDown(0)){System.exit(0);}
}else{exit = exitGris;}
}
public int getID() {
return 0;
}
} |
Partager