/** * @see org.newdawn.slick.state.BasicGameState#keyReleased(int, char) */ public void keyReleased(int key, char c) { if (key == Input.KEY_2) { GameState target = game.getState(TestState2.ID); final long start = System.currentTimeMillis(); CrossStateTransition t = new CrossStateTransition(target) { public boolean isComplete() { return (System.currentTimeMillis() - start) > 2000; } public void init(GameState firstState, GameState secondState) { } }; game.enterState(TestState2.ID, t, new EmptyTransition()); } if (key == Input.KEY_3) { game.enterState(TestState3.ID, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); } }
/** * @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)); } }
@Override public void update(GameContainer gc, StateBasedGame game, int delta) throws SlickException { if(gameStart.inBounds(Globals.mouse.getPosition().x, Globals.mouse.getPosition().y)) { gameStart.mouseEnter(); if(Globals.mouse.isMouseDown()) { Globals.resetEntityNum(); Globals.resetInputs(); game.enterState(GameState.ID, new FadeOutTransition(), new FadeInTransition()); } } else gameStart.mouseExit(); if(credits.inBounds(Globals.mouse.getPosition().x, Globals.mouse.getPosition().y)) credits.mouseEnter(); else credits.mouseExit(); if(exit.inBounds(Globals.mouse.getPosition().x, Globals.mouse.getPosition().y)) { exit.mouseEnter(); if(Globals.mouse.isMouseDown()) gc.exit(); } else exit.mouseExit(); MusicPlayer.getInstance().update(); }
private void backToMainMenu(StateBasedGame sbg) { pressedEscape = false; caseMonsterAnimation = 2; pressedEnter = false; monsterPicking = true; songPicking = false; p1Picking = true; p2Picking = false; for (Music music : musicSongChoices) { if (music.playing()) { music.stop(); } } MainMenuState.resumeMusic(); sbg.enterState(BeatBitBeatMain.getMainMenu(), new FadeOutTransition(), new FadeInTransition()); }
@Override public void update(GameContainer gc, StateBasedGame sbg, int i) throws SlickException { Input input = gc.getInput(); xMouse = input.getMouseX(); yMouse = input.getMouseY(); if (coordHumanP1.getX() != 100){ coordHumanP1.setX(coordHumanP1.getX() - 15); coordHumanP2.setX(coordHumanP2.getX() + 15); } if (pressable){ if (enterPressed){ pressable = false; enterPressed = false; sbg.enterState(BeatBitBeatMain.getGameProper(), new FadeOutTransition(), new FadeInTransition()); } } // }
@Override public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { String ip = "127.0.0.1"; boolean inp = false; Input input = container.getInput(); if(input.isKeyDown(Input.KEY_1)){ (new Server()).start(); inp = true; } else if(input.isKeyDown(Input.KEY_2)){ ip = JOptionPane.showInputDialog("Connect to server using ip."); inp = true; } if(inp){ this.game.enterState(Game.ID, new FadeOutTransition(org.newdawn.slick.Color.black), new FadeInTransition(org.newdawn.slick.Color.black)); new InitThread(ip, (Game) game.getState(Game.ID)).start(); } }
public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { super.update(container, game, delta); if (mResource != null) { try { mResource.load(); } catch (IOException e) { throw new SlickException("Failed to load: " + mResource.getDescription(), e); } mResource = null; } mRemaining = LoadingList.get().getRemainingResources(); mTotal = LoadingList.get().getTotalResources(); if (LoadingList.get().getRemainingResources() > 0) { mResource = LoadingList.get().getNext(); } else { ((Music)DatasManager.getInstance().getFile("Music.menu")).loop(); game.enterState(1, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); } }
/** * Starts the game. */ private void startGame() { if (MusicController.isTrackLoading()) return; Beatmap beatmap = MusicController.getBeatmap(); if (focusNode == null || beatmap != focusNode.getSelectedBeatmap()) { UI.getNotificationManager().sendBarNotification("Unable to load the beatmap audio."); return; } // turn on "auto" mod if holding "ctrl" key if (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) { if (!GameMod.AUTO.isActive()) GameMod.AUTO.toggle(true); } SoundController.playSound(SoundEffect.MENUHIT); MultiClip.destroyExtraClips(); Game gameState = (Game) game.getState(Opsu.STATE_GAME); gameState.loadBeatmap(beatmap); gameState.setPlayState(Game.PlayState.FIRST_LOAD); gameState.setReplay(null); game.enterState(Opsu.STATE_GAME, new EasedFadeOutTransition(), new FadeInTransition()); }
private void gameoverInput(GameContainer gc, StateBasedGame sbg, Input input) throws SlickException { if(input.isKeyPressed(Input.KEY_RIGHT)){ if(!selection){ selection = true; } }else if(input.isKeyPressed(Input.KEY_LEFT)){ if(selection){ selection = false; } }else if(input.isKeyPressed(Input.KEY_ENTER)){ if(selection){ status.get(0).setData(false); sbg.getState(Spacerun.MAINMENUSTATE).init(gc, sbg); sbg.enterState(Spacerun.MAINMENUSTATE, new FadeOutTransition(), new FadeInTransition()); }else{ sbg.getState(Spacerun.GAMESTATE).init(gc, sbg); sbg.enterState(Spacerun.GAMESTATE, new FadeOutTransition(), new FadeInTransition()); } } }
@Override public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException { Input input = gc.getInput(); if(input.isKeyPressed(Input.KEY_ESCAPE)){ sbg.getState(Spacerun.MAINMENUSTATE).init(gc, sbg); sbg.enterState(Spacerun.MAINMENUSTATE, new FadeOutTransition(), new FadeInTransition()); } if(input.isKeyPressed(Input.KEY_UP)){ menuSelection = true; }else if(input.isKeyPressed(Input.KEY_DOWN)){ menuSelection = false; }else if(input.isKeyPressed(Input.KEY_ENTER)){ if(menuSelection){ if((boolean)status.get(1).getData()){ status.get(1).setData(false); }else{ status.get(1).setData(true); } }else{ sbg.getState(Spacerun.MAINMENUSTATE).init(gc, sbg); sbg.enterState(Spacerun.MAINMENUSTATE, new FadeOutTransition(), new FadeInTransition()); } } }
@Override public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException{ Input input = gc.getInput(); if(input.isKeyPressed(Input.KEY_LEFT)){ selection = false; }else if(input.isKeyPressed(Input.KEY_RIGHT)){ selection = true; }else if(input.isKeyPressed(Input.KEY_ENTER)){ if(selection){ fHandler.deleteHighscore(); sbg.getState(Spacerun.HIGHSCORESTATE).init(gc, sbg); //we need to update the screen; the easiest way sbg.enterState(Spacerun.HIGHSCORESTATE, new FadeOutTransition(), new FadeInTransition()); }else{ sbg.getState(Spacerun.MAINMENUSTATE).init(gc, sbg); sbg.enterState(Spacerun.MAINMENUSTATE, new FadeOutTransition(), new FadeInTransition()); } } if(input.isKeyPressed(Input.KEY_ESCAPE)){ sbg.getState(Spacerun.MAINMENUSTATE).init(gc, sbg); sbg.enterState(Spacerun.MAINMENUSTATE, new FadeOutTransition(), new FadeInTransition()); } }
@Override public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { if(!loadComplete) { if(makeFighter(fileName, currentFighter)) { if(loadingSecondCharacter) { loadComplete = true; System.out.println("LOAD COMPLETE"); } else { fileName = fighter2; loadingSecondCharacter = true; } } } if(loadComplete) { //if(flashyThingDone || skipButtonPressed) game.enterState(Manager.StateIndex.FIGHT.ordinal(), new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); } }
/** * @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 proceedToGameProper(StateBasedGame sbg) { // stop playing preview of songs for (int i = 0; i < musicSongChoices.length; i++) { musicSongChoices[i].stop(); } GameProperState.setMonsterP1(monsterP1); GameProperState.setMonsterP2(monsterP2); // TODO low prio. 3..2..1.. Countdown at GameProperState before music starts sbg.enterState(BeatBitBeatMain.getVersusPreview(), new FadeOutTransition(), new FadeInTransition()); }
@Override public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int i) throws SlickException { if (pressedEscape) { pressedEscape = false; stateBasedGame.enterState(BeatBitBeatMain.getMainMenu(), new FadeOutTransition(), new FadeInTransition()); } }
@Override public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int i) throws SlickException { Input input = gameContainer.getInput(); xMouse = input.getMouseX(); yMouse = input.getMouseY(); if (pressedEsc) { pressedEsc = false; stateBasedGame.enterState(BeatBitBeatMain.getMainMenu(), new FadeOutTransition(), new FadeInTransition()); } }
public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException { this.delta = delta; // for printing. temporary Input input = gc.getInput(); xMouse = input.getMouseX(); yMouse = input.getMouseY(); // Enter selected state if (enterPressed) { enterPressed = false; try { if (yIndicator == coordsArrows[0].getY()) { // if indicator is pointing to Start btn indexOfSelectedState = BeatBitBeatMain.getCharacterSelection(); // get ID for state } else if (yIndicator == coordsArrows[1].getY()) { // if indicator is pointing to options btn indexOfSelectedState = BeatBitBeatMain.getOptions(); } else if (yIndicator == coordsArrows[2].getY()) { // if indicator is pointing to credits btn indexOfSelectedState = BeatBitBeatMain.getCredits(); } else if (yIndicator == coordsArrows[3].getY()) { // if indicator is pointing to exit btn System.exit(0); } } catch (ArrayIndexOutOfBoundsException e){ } // enter state indicated by indexOfSelectedState sbg.enterState(indexOfSelectedState, new FadeOutTransition(), new FadeInTransition()); } // end of if (enterPressed) }
@Override public void mouseClicked(int button, int x, int y, int clickCount) { if (startButton.contains(x, y) && !clicked) { clicked = true; SFX.playSound(G.SELECT_SOUND); game.enterState(Launcher.GAME_STATE, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); } if (exitButton.contains(x, y) && !clicked) { clicked = true; SFX.playSound(G.SELECT_SOUND); System.exit(0); } }
@Override public void keyPressed(int key, char c) { if (key == Input.KEY_ESCAPE) { if (!pressEscapeState) { pressEscapeState = true; } else { game.enterState(Launcher.MENU_STATE, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); } } else { pressEscapeState = false; } }
@Override public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { time += delta; if(time > DELAY){ game.enterState(MainMenu.ID, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); } }
@Override protected void layout() { if (mLoaded) { lblStatus.setText(""); mLoginScene.getGame().enterState(2, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); mLoaded = false; } // login panel is centered adjustSize(); setPosition((getParent().getWidth() - getWidth()) / 2, (getParent().getHeight() - getHeight()) / 2); }
@Override public boolean closeRequested() { int id = this.getCurrentStateID(); // intercept close requests in game-related states and return to song menu if (id == STATE_GAME || id == STATE_GAMEPAUSEMENU || id == STATE_GAMERANKING) { // start playing track at preview position SongMenu songMenu = (SongMenu) this.getState(Opsu.STATE_SONGMENU); if (id == STATE_GAMERANKING) { GameData data = ((GameRanking) this.getState(Opsu.STATE_GAMERANKING)).getGameData(); if (data != null && data.isGameplay()) songMenu.resetTrackOnLoad(); } else { if (id == STATE_GAME) { MusicController.pause(); MusicController.setPitch(1.0f); MusicController.resume(); } else songMenu.resetTrackOnLoad(); } // reset game data if (UI.getCursor().isBeatmapSkinned()) UI.getCursor().reset(); songMenu.resetGameDataOnLoad(); this.enterState(Opsu.STATE_SONGMENU, new EasedFadeOutTransition(), new FadeInTransition()); return false; } // show confirmation dialog if any downloads are active if (DownloadList.get().hasActiveDownloads() && UI.showExitConfirmation(DownloadList.EXIT_CONFIRMATION)) return false; if (Updater.get().getStatus() == Updater.Status.UPDATE_DOWNLOADING && UI.showExitConfirmation(Updater.EXIT_CONFIRMATION)) return false; return true; }
@Override public void mousePressed(int button, int x, int y) { if (button == Input.MOUSE_MIDDLE_BUTTON) return; boolean loseState = (gameState.getPlayState() == Game.PlayState.LOSE); if (continueButton.contains(x, y) && !loseState) { SoundController.playSound(SoundEffect.MENUBACK); gameState.setPlayState(Game.PlayState.NORMAL); game.enterState(Opsu.STATE_GAME); } else if (retryButton.contains(x, y)) { SoundController.playSound(SoundEffect.MENUHIT); gameState.setPlayState(Game.PlayState.RETRY); game.enterState(Opsu.STATE_GAME); } else if (backButton.contains(x, y)) { SoundController.playSound(SoundEffect.MENUBACK); ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).resetGameDataOnLoad(); if (loseState) MusicController.playAt(MusicController.getBeatmap().previewTime, true); else MusicController.resume(); if (UI.getCursor().isBeatmapSkinned()) UI.getCursor().reset(); MusicController.setPitch(1.0f); game.enterState(Opsu.STATE_SONGMENU, new EasedFadeOutTransition(), new FadeInTransition()); } }
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUHIT); BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode(); ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.BEATMAP, node); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition()); }
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUHIT); BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode(); node.getBeatmapSet().setFavorite(true); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition()); }
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUHIT); BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode(); node.getBeatmapSet().setFavorite(false); ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.BEATMAP_FAVORITE); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition()); }