Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javagame;
- import java.awt.*;
- import org.lwjgl.input.Mouse;
- import org.newdawn.slick.Color;
- import org.newdawn.slick.Font;
- import org.newdawn.slick.GameContainer;
- import org.newdawn.slick.Graphics;
- import org.newdawn.slick.Input;
- import org.newdawn.slick.SlickException;
- import org.newdawn.slick.state.BasicGameState;
- import org.newdawn.slick.state.StateBasedGame;
- public class Room1Lock extends BasicGameState{
- Room1 r1 = new Room1(1);
- int digitOne = 0;
- int digitTwo = 1;
- int digitThree = 2;
- public Room1Lock(int state){
- }
- public void init(GameContainer gc, StateBasedGame sbg) throws SlickException{
- }
- public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException{
- //Places background
- g.setColor(Color.gray);
- g.fillRect(300, 100, 400, 400);
- //Places lock inputs
- g.setColor(Color.yellow);
- g.fillOval(370, 275, 50, 50);
- g.fillOval(470, 275, 50, 50);
- g.fillOval(570, 275, 50, 50);
- //Draws the lock digits
- g.setColor(Color.black);
- g.drawString(digitOne + "", 390, 290);
- g.drawString(digitTwo + "", 490, 290);
- g.drawString(digitThree + "", 590, 290);
- //Draws Help
- g.setColor(Color.white);
- g.drawString("Hover over the numbers and press the number\non the keyboard you want to change it to.", 250, 150);
- }
- public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException{
- Input input = gc.getInput();
- int x = Mouse.getX();
- int y = Mouse.getY();
- //Change variables
- //inputOne
- if(((x >= 370 && x <= 420) && (y >= 275 && y <= 325)) && input.isKeyDown(input.KEY_0)){
- digitOne = 0;
- }
- if(((x >= 370 && x <= 420) && (y >= 275 && y <= 325)) && input.isKeyDown(input.KEY_1)){
- digitOne = 1;
- }
- if(((x >= 370 && x <= 420) && (y >= 275 && y <= 325)) && input.isKeyDown(input.KEY_2)){
- digitOne = 2;
- }
- if(((x >= 370 && x <= 420) && (y >= 275 && y <= 325)) && input.isKeyDown(input.KEY_3)){
- digitOne = 3;
- }
- //inputTwo
- if(((x >= 470 && x <= 520) && (y >= 275 && y <= 325)) && input.isKeyDown(input.KEY_0)){
- digitTwo = 0;
- }
- if(((x >= 470 && x <= 520) && (y >= 275 && y <= 325)) && input.isKeyDown(input.KEY_1)){
- digitTwo = 1;
- }
- if(((x >= 470 && x <= 520) && (y >= 275 && y <= 325)) && input.isKeyDown(input.KEY_2)){
- digitTwo = 2;
- }
- if(((x >= 470 && x <= 520) && (y >= 275 && y <= 325)) && input.isKeyDown(input.KEY_3)){
- digitTwo = 3;
- }
- if((digitOne == 2 && digitTwo == 3) && digitThree == 2){
- Room1 r1 = new Room1(1);
- r1.setLocked(false);
- }
- //Check to see if leaving
- if(input.isKeyDown(input.KEY_ESCAPE)){
- sbg.enterState(1);
- }
- }
- public int getDigitOne(){
- return digitOne;
- }
- public int getDigitTwo(){
- return digitTwo;
- }
- public int getDigitThree(){
- return digitThree;
- }
- public int getID(){
- return 100;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement