/** * @see org.newdawn.slick.BasicGame#keyPressed(int, char) */ public void keyPressed(int key, char c) { if (key == Input.KEY_ESCAPE) { System.exit(0); } if(key == Input.KEY_N) { curTest++; curTest %= NUMTESTS; } if(key == Input.KEY_C) { colorIndex++; colorIndex %= 4; setColors(); } if(key == Input.KEY_T) { hideOverlay = !hideOverlay; } }
/** * Create a new mouse over area * * @param container * The container displaying the mouse over area * @param image * The normalImage to display * @param shape * The shape defining the area of the mouse sensitive zone */ public MouseOverArea(GUIContext container, Image image, Shape shape) { super(container); area = shape; normalImage = image; currentImage = image; mouseOverImage = image; mouseDownImage = image; currentColor = normalColor; state = NORMAL; Input input = container.getInput(); over = area.contains(input.getMouseX(), input.getMouseY()); mouseDown = input.isMouseButtonDown(0); updateImage(); }
/** * @see org.newdawn.slick.BasicGame#keyReleased(int, char) */ public void keyReleased(int key, char c) { if (key == Input.KEY_Q) { scaleUp = false; } if (key == Input.KEY_A) { scaleDown = false; } if( key == Input.KEY_LEFT) { moveLeft = false; } if( key == Input.KEY_UP ) { moveUp = false; } if( key == Input.KEY_RIGHT ) { moveRight = false; } if( key == Input.KEY_DOWN ) { moveDown = false; } }
/** * @see org.newdawn.slick.state.BasicGameState#keyReleased(int, char) */ public void keyReleased(int key, char c) { if (key == Input.KEY_DOWN) { selected++; if (selected >= options.length) { selected = 0; } } if (key == Input.KEY_UP) { selected--; if (selected < 0) { selected = options.length - 1; } } if (key == Input.KEY_1) { game.enterState(TestState1.ID, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); } if (key == Input.KEY_2) { game.enterState(TestState2.ID, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); } }
/** * @see org.newdawn.slick.BasicGame#update(org.newdawn.slick.GameContainer, int) */ public void update(GameContainer container, int delta) { lshift = container.getInput().isKeyDown(Input.KEY_LSHIFT); rshift = container.getInput().isKeyDown(Input.KEY_RSHIFT); space = container.getInput().isKeyDown(Input.KEY_SPACE); if (controllerLeft[0]) { x -= delta * 0.1f; } if (controllerRight[0]) { x += delta * 0.1f; } if (controllerUp[0]) { y -= delta * 0.1f; } if (controllerDown[0]) { y += delta * 0.1f; } }
@Override public void update(GameContainer gc, StateBasedGame sbg, int i) throws SlickException { if (shouldToggleFullscreen) { shouldToggleFullscreen = false; boolean fs = !gc.isFullscreen(); AppGameContainer agc = (AppGameContainer)gc; agc.setDisplayMode(fs ? agc.getScreenWidth() : Application.DISPLAY_WIDTH, fs ? agc.getScreenHeight() : Application.DISPLAY_HEIGHT, fs); } if (gc.getInput().isKeyPressed(Input.KEY_ENTER)) { click.play(1.0f, CLICK_VOLUME); mainMenu.fade(1000, 0.0f, true); sbg.enterState(Application.GAME, new FadeOutTransition(Color.black, 1000), new EmptyTransition()); } if (gc.getInput().isKeyPressed(Input.KEY_C)) { sbg.enterState(Application.CREDITS); } }
/** * @see org.newdawn.slick.BasicGame#update(org.newdawn.slick.GameContainer, int) */ public void update(GameContainer container, int delta) throws SlickException { ang += delta * 0.1f; if (container.getInput().isKeyDown(Input.KEY_LEFT)) { x -= delta * 0.1f; } if (container.getInput().isKeyDown(Input.KEY_RIGHT)) { x += delta * 0.1f; } if (container.getInput().isKeyDown(Input.KEY_UP)) { y -= delta * 0.1f; } if (container.getInput().isKeyDown(Input.KEY_DOWN)) { y += delta * 0.1f; } }
/** * @see org.newdawn.slick.BasicGame#keyPressed(int, char) */ public void keyPressed(int key, char c) { if (key == Input.KEY_ESCAPE) { System.exit(0); } if (key == Input.KEY_F2) { app.setDefaultMouseCursor(); } if (key == Input.KEY_F1) { if (app != null) { try { app.setDisplayMode(640,480,false); } catch (SlickException e) { Log.error(e); } } } }
/** * @see org.newdawn.slick.BasicGame#keyPressed(int, char) */ public void keyPressed(int key, char c) { if (key == Input.KEY_ESCAPE) { System.exit(0); } if (key == Input.KEY_Q) { scaleUp = true; } if (key == Input.KEY_A) { scaleDown = true; } if( key == Input.KEY_LEFT) { moveLeft = true; } if( key == Input.KEY_UP ) { moveUp = true; } if( key == Input.KEY_RIGHT ) { moveRight = true; } if( key == Input.KEY_DOWN ) { moveDown = true; } }
@Override public void keyReleased(int key, char c) { if(key == Input.KEY_GRAVE) { console.setPauseTime(time); consoleOpen = !consoleOpen; } else if((key == Input.KEY_P) && !consoleOpen) { if(!paused) MusicPlayer.getInstance().pause(); else MusicPlayer.getInstance().resume(); paused = !paused; } else { if(consoleOpen) { console.keyReleased(key, c); } else { Globals.inputs.remove(key); Globals.released.add(key); } } }
/** * @see org.newdawn.slick.BasicGame#keyPressed(int, char) */ public void keyPressed(int key, char c) { if (key == Input.KEY_ESCAPE) { System.exit(0); } if (key == Input.KEY_Q) { scaleUp = true; } if (key == Input.KEY_A) { scaleDown = true; } }
/** * @see org.newdawn.slick.BasicGame#keyPressed(int, char) */ public void keyPressed(int key, char c) { if (key == Input.KEY_ESCAPE) { System.exit(0); } if (key == Input.KEY_SPACE) { visible = !visible; } }
/** * @see org.newdawn.slick.BasicGame#update(org.newdawn.slick.GameContainer, int) */ public void update(GameContainer container, int delta) throws SlickException { fire.update(delta); if (container.getInput().isKeyPressed(Input.KEY_P)) { writeTo("ImageOutTest.png"); } if (container.getInput().isKeyPressed(Input.KEY_J)) { writeTo("ImageOutTest.jpg"); } if (container.getInput().isKeyPressed(Input.KEY_T)) { writeTo("ImageOutTest.tga"); } }
/** * @see org.newdawn.slick.BasicGame#keyPressed(int, char) */ public void keyPressed(int key, char c) { if (key == Input.KEY_SPACE) { if (image == gif) { image = tga; } else { image = gif; } } }
/** * @see org.newdawn.slick.BasicGame#keyPressed(int, char) */ public void keyPressed(int key, char c) { currentGame.keyPressed(key, c); if (key == Input.KEY_ENTER) { nextGame(); } }
/** * @see org.newdawn.slick.state.GameState#update(org.newdawn.slick.GameContainer, org.newdawn.slick.state.StateBasedGame, int) */ public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { if (container.getInput().isKeyPressed(Input.KEY_SPACE)) { Transition[] pair = getNextTransitionPair(); game.enterState(next, pair[0], pair[1]); } }
/** * Update data map etc */ public void update(GameContainer container, int delta) throws SlickException { if (container.getInput().isKeyPressed(Input.KEY_1)) { showLinks = !showLinks; } if (container.getInput().isKeyPressed(Input.KEY_2)) { showSpaces = !showSpaces; } }
/** * @see org.newdawn.slick.BasicGame#keyPressed(int, char) */ public void keyPressed(int key, char c) { if (key == Input.KEY_R) { rotating = !rotating; } if (key == Input.KEY_ESCAPE) { container.exit(); } }
/** * @see org.newdawn.slick.BasicGame#keyPressed(int, char) */ public void keyPressed(int key, char c) { if (key == Input.KEY_ESCAPE) { container.exit(); } if (key == Input.KEY_K) { explosionEmitter.wrapUp(); } }
/** * @see org.newdawn.slick.BasicGame#keyReleased(int, char) */ public void keyReleased(int key, char c) { if (key == Input.KEY_Q) { scaleUp = false; } if (key == Input.KEY_A) { scaleDown = false; } }
/** * @see org.newdawn.slick.state.BasicGameState#keyReleased(int, char) */ public void keyReleased(int key, char c) { if (key == Input.KEY_1) { game.enterState(TestState1.ID, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); } if (key == Input.KEY_3) { game.enterState(TestState3.ID, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); } }
private void setControlKeys() { if(this instanceof PacMan) { comands[0] = Input.KEY_UP; comands[1] = Input.KEY_DOWN; comands[2] = Input.KEY_LEFT; comands[3] = Input.KEY_RIGHT; } if(this instanceof Blinky) { comands[0] = Input.KEY_W; comands[1] = Input.KEY_S; comands[2] = Input.KEY_A; comands[3] = Input.KEY_D; } if(this instanceof Clyde) { comands[0] = Input.KEY_T; comands[1] = Input.KEY_G; comands[2] = Input.KEY_F; comands[3] = Input.KEY_H; } if(this instanceof Inky) { comands[0] = Input.KEY_I; comands[1] = Input.KEY_K; comands[2] = Input.KEY_J; comands[3] = Input.KEY_L; } if(this instanceof Pinky) { comands[0] = Input.KEY_5; comands[1] = Input.KEY_2; comands[2] = Input.KEY_1; comands[3] = Input.KEY_3; } }
/** * @see org.newdawn.slick.BasicGame#keyPressed(int, char) */ public void keyPressed(int key, char c) { if (key == Input.KEY_ESCAPE) { System.exit(0); } if (key == Input.KEY_F1) { if (app != null) { try { app.setDisplayMode(600, 600, false); app.reinit(); } catch (Exception e) { Log.error(e); } } } }
/** * @see org.newdawn.slick.BasicGame#keyPressed(int, char) */ public void keyPressed(int key, char c) { count++; if (key == Input.KEY_SPACE) { if (input.isKeyRepeatEnabled()) { input.disableKeyRepeat(); } else { input.enableKeyRepeat(300,100); } } }
/** * @see org.newdawn.slick.BasicGame#keyPressed(int, char) */ public void keyPressed(int key, char c) { if (key == Input.KEY_ESCAPE) { System.exit(0); } if (key == Input.KEY_SPACE) { clip = !clip; } }
/** * @see org.newdawn.slick.BasicGame#keyPressed(int, char) */ public void keyPressed(int key, char c) { if (key == Input.KEY_1) { world = false; clip = false; } if (key == Input.KEY_2) { world = false; clip = true; } if (key == Input.KEY_3) { world = true; clip = false; } }
/** * If user press a new button, this method memorizes it. * @param input * @param n * @return */ public boolean otherKeyPress(Input input, int n) { if ((input.isKeyDown(comands[1])) && checkBlockDown() && comands[1] != n) return true; else if ((input.isKeyDown(comands[0])) && checkBlockUp() && comands[0] != n) return true; else if ((input.isKeyDown(comands[2])) && checkBlockLeft() && comands[2] != n) return true; else if((input.isKeyDown(comands[3])) && checkBlockRight() && comands[3] != n) return true; else return false; }
/** * @see org.newdawn.slick.BasicGame#update(org.newdawn.slick.GameContainer, int) */ public void update(GameContainer container, int delta) { if (container.getInput().isKeyDown(Input.KEY_1)) { manual.update(delta); } if (start >= 0) { start -= delta; } }
/** * @see org.newdawn.slick.BasicGame#keyPressed(int, char) */ public void keyPressed(int key, char c) { if (key == Input.KEY_ESCAPE) { container.exit(); } if (key == Input.KEY_SPACE) { limited.restart(); } }