Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2014
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. package javagame;
  2.  
  3. import java.awt.*;
  4.  
  5. import org.lwjgl.input.Mouse;
  6. import org.newdawn.slick.Color;
  7. import org.newdawn.slick.Font;
  8. import org.newdawn.slick.GameContainer;
  9. import org.newdawn.slick.Graphics;
  10. import org.newdawn.slick.Input;
  11. import org.newdawn.slick.SlickException;
  12. import org.newdawn.slick.state.BasicGameState;
  13. import org.newdawn.slick.state.StateBasedGame;
  14.  
  15. public class Room1Lock extends BasicGameState{
  16.  
  17. Room1 r1 = new Room1(1);
  18. int digitOne = 0;
  19. int digitTwo = 1;
  20. int digitThree = 2;
  21.  
  22. public Room1Lock(int state){
  23.  
  24. }
  25.  
  26. public void init(GameContainer gc, StateBasedGame sbg) throws SlickException{
  27.  
  28. }
  29.  
  30. public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException{
  31. //Places background
  32. g.setColor(Color.gray);
  33. g.fillRect(300, 100, 400, 400);
  34.  
  35. //Places lock inputs
  36. g.setColor(Color.yellow);
  37. g.fillOval(370, 275, 50, 50);
  38. g.fillOval(470, 275, 50, 50);
  39. g.fillOval(570, 275, 50, 50);
  40.  
  41. //Draws the lock digits
  42. g.setColor(Color.black);
  43. g.drawString(digitOne + "", 390, 290);
  44. g.drawString(digitTwo + "", 490, 290);
  45. g.drawString(digitThree + "", 590, 290);
  46.  
  47. //Draws Help
  48. g.setColor(Color.white);
  49. g.drawString("Hover over the numbers and press the number\non the keyboard you want to change it to.", 250, 150);
  50. }
  51.  
  52. public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException{
  53. Input input = gc.getInput();
  54. int x = Mouse.getX();
  55. int y = Mouse.getY();
  56.  
  57. //Change variables
  58. //inputOne
  59. if(((x >= 370 && x <= 420) && (y >= 275 && y <= 325)) && input.isKeyDown(input.KEY_0)){
  60. digitOne = 0;
  61. }
  62. if(((x >= 370 && x <= 420) && (y >= 275 && y <= 325)) && input.isKeyDown(input.KEY_1)){
  63. digitOne = 1;
  64. }
  65. if(((x >= 370 && x <= 420) && (y >= 275 && y <= 325)) && input.isKeyDown(input.KEY_2)){
  66. digitOne = 2;
  67. }
  68. if(((x >= 370 && x <= 420) && (y >= 275 && y <= 325)) && input.isKeyDown(input.KEY_3)){
  69. digitOne = 3;
  70. }
  71.  
  72. //inputTwo
  73. if(((x >= 470 && x <= 520) && (y >= 275 && y <= 325)) && input.isKeyDown(input.KEY_0)){
  74. digitTwo = 0;
  75. }
  76. if(((x >= 470 && x <= 520) && (y >= 275 && y <= 325)) && input.isKeyDown(input.KEY_1)){
  77. digitTwo = 1;
  78. }
  79. if(((x >= 470 && x <= 520) && (y >= 275 && y <= 325)) && input.isKeyDown(input.KEY_2)){
  80. digitTwo = 2;
  81. }
  82. if(((x >= 470 && x <= 520) && (y >= 275 && y <= 325)) && input.isKeyDown(input.KEY_3)){
  83. digitTwo = 3;
  84. }
  85. if((digitOne == 2 && digitTwo == 3) && digitThree == 2){
  86. Room1 r1 = new Room1(1);
  87. r1.setLocked(false);
  88. }
  89.  
  90. //Check to see if leaving
  91. if(input.isKeyDown(input.KEY_ESCAPE)){
  92. sbg.enterState(1);
  93. }
  94.  
  95. }
  96. public int getDigitOne(){
  97. return digitOne;
  98. }
  99. public int getDigitTwo(){
  100. return digitTwo;
  101. }
  102. public int getDigitThree(){
  103. return digitThree;
  104. }
  105.  
  106. public int getID(){
  107. return 100;
  108. }
  109.  
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement