Advertisement
Guest User

Untitled

a guest
Apr 9th, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. package javaGame;
  2.  
  3. import org.newdawn.slick.*;
  4. import org.newdawn.slick.state.*;
  5. import org.lwjgl.input.Mouse;
  6.  
  7. public class Menu extends BasicGameState{
  8.  
  9. public String mousePos = "No input.";
  10. public int xPos;
  11. public int yPos;
  12. public boolean hasNotClicked;
  13.  
  14. public Menu (int state){
  15.  
  16. }
  17. public void init(GameContainer gc, StateBasedGame sbg)throws SlickException{
  18.  
  19. }
  20. public void render(GameContainer gc, StateBasedGame sbg, Graphics g)throws SlickException{
  21. //Images
  22. Image playbutton = new Image("res/Play Dark Age Button.png");
  23. Image settingsbutton = new Image("res/Options Button.png");
  24. Image creditsbutton = new Image("res/Credits Button.png");
  25. //Buttons
  26. g.drawImage(playbutton, 300, 240);
  27. g.drawImage(settingsbutton, 300, 285);
  28. g.drawImage(creditsbutton, 300, 330);
  29. //Mouse Position
  30. g.drawString(mousePos, 10, 25);
  31. }
  32. public void update(GameContainer gc, StateBasedGame sbg, int delta)throws SlickException{
  33. xPos = Mouse.getX();
  34. yPos = 600 - Mouse.getY();
  35. mousePos = (xPos + ", " + yPos);
  36.  
  37. if((xPos>=300 && xPos <= 510)&&(yPos>=240&&yPos<=275)){
  38. if(Mouse.isButtonDown(0)){
  39. sbg.enterState(1);
  40. }
  41. }
  42. if((xPos>=300 && xPos <= 510)&&(yPos>=285&&yPos<=320)){
  43. if(Mouse.isButtonDown(0)){
  44. sbg.enterState(3);
  45. }
  46. }
  47. if((xPos>=300 && xPos <= 510)&&(yPos>=330&&yPos<=365)){
  48. if(Mouse.isButtonDown(0)){
  49. sbg.enterState(4);
  50. }
  51. }
  52. }
  53.  
  54. public int getID(){
  55. return 0;
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement