Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaGame;
- import org.newdawn.slick.*;
- import org.newdawn.slick.state.*;
- import org.lwjgl.input.Mouse;
- public class Menu extends BasicGameState{
- public String mousePos = "No input.";
- public int xPos;
- public int yPos;
- public boolean hasNotClicked;
- public Menu (int state){
- }
- public void init(GameContainer gc, StateBasedGame sbg)throws SlickException{
- }
- public void render(GameContainer gc, StateBasedGame sbg, Graphics g)throws SlickException{
- //Images
- Image playbutton = new Image("res/Play Dark Age Button.png");
- Image settingsbutton = new Image("res/Options Button.png");
- Image creditsbutton = new Image("res/Credits Button.png");
- //Buttons
- g.drawImage(playbutton, 300, 240);
- g.drawImage(settingsbutton, 300, 285);
- g.drawImage(creditsbutton, 300, 330);
- //Mouse Position
- g.drawString(mousePos, 10, 25);
- }
- public void update(GameContainer gc, StateBasedGame sbg, int delta)throws SlickException{
- xPos = Mouse.getX();
- yPos = 600 - Mouse.getY();
- mousePos = (xPos + ", " + yPos);
- if((xPos>=300 && xPos <= 510)&&(yPos>=240&&yPos<=275)){
- if(Mouse.isButtonDown(0)){
- sbg.enterState(1);
- }
- }
- if((xPos>=300 && xPos <= 510)&&(yPos>=285&&yPos<=320)){
- if(Mouse.isButtonDown(0)){
- sbg.enterState(3);
- }
- }
- if((xPos>=300 && xPos <= 510)&&(yPos>=330&&yPos<=365)){
- if(Mouse.isButtonDown(0)){
- sbg.enterState(4);
- }
- }
- }
- public int getID(){
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement