org.newdawn.slick.state.StateBasedGame Java Examples
The following examples show how to use
org.newdawn.slick.state.StateBasedGame.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StateConfigRuleSelect.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void enter(GameContainer container, StateBasedGame game) throws SlickException { strFileList = getRuleFileList(); createRuleEntries(strFileList, style); strRuleNameList = extractRuleNameListFromRuleEntries(); strRuleFileList = extractFileNameListFromRuleEntries(); list = strRuleNameList; maxCursor = list.length-1; if(style == 0) { strCurrentFileName = NullpoMinoSlick.propGlobal.getProperty(player + ".rulefile", ""); strCurrentRuleName = NullpoMinoSlick.propGlobal.getProperty(player + ".rulename", ""); } else { strCurrentFileName = NullpoMinoSlick.propGlobal.getProperty(player + ".rulefile." + style, ""); strCurrentRuleName = NullpoMinoSlick.propGlobal.getProperty(player + ".rulename." + style, ""); } cursor = 0; for(int i = 0; i < ruleEntries.size(); i++) { if(ruleEntries.get(i).filename.equals(strCurrentFileName)) { cursor = i; } } }
Example #2
Source File: StateTitle.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void renderImpl(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { // Background g.drawImage(ResourceHolderSlick.imgTitle, 0, 0); // Menu NormalFontSlick.printFontGrid(1, 1, "NULLPOMINO", NormalFontSlick.COLOR_ORANGE); NormalFontSlick.printFontGrid(1, 2, "VERSION " + GameManager.getVersionString(), NormalFontSlick.COLOR_ORANGE); renderChoices(2, 4, CHOICES); NormalFontSlick.printTTFFont(16, 432, NullpoMinoSlick.getUIText(UI_TEXT[cursor])); if(UpdateChecker.isNewVersionAvailable(GameManager.getVersionMajor(), GameManager.getVersionMinor())) { String strTemp = String.format(NullpoMinoSlick.getUIText("Title_NewVersion"), UpdateChecker.getLatestVersionFullString(), UpdateChecker.getStrReleaseDate()); NormalFontSlick.printTTFFont(16, 416, strTemp); } }
Example #3
Source File: GameRanking.java From opsu with GNU General Public License v3.0 | 6 votes |
@Override public void enter(GameContainer container, StateBasedGame game) throws SlickException { UI.enter(); Display.setTitle(game.getTitle()); if (!data.isGameplay()) { if (!MusicController.isTrackDimmed()) MusicController.toggleTrackDimmed(0.5f); replayButton.setY(retryY); animationProgress.setTime(animationProgress.getDuration()); } else { SoundController.playSound(SoundEffect.APPLAUSE); retryButton.resetHover(); if (GameMod.AUTO.isActive()) { replayButton.setY(retryY); animationProgress.setTime(animationProgress.getDuration()); } else { replayButton.setY(replayY); animationProgress.setTime(0); } } replayButton.resetHover(); loadReplay(); }
Example #4
Source File: StateSelectMode.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected boolean onDecide(GameContainer container, StateBasedGame game, int delta) { ResourceHolderSlick.soundManager.play("decide"); if(isTopLevel && (cursor == list.length - 1)) { // More... NullpoMinoSlick.propGlobal.setProperty("name.mode.toplevel", list[cursor]); game.enterState(StateSelectModeFolder.ID); } else { // Go to rule selector if(isTopLevel) { NullpoMinoSlick.propGlobal.setProperty("name.mode.toplevel", list[cursor]); } if(strCurrentFolder.length() > 0) { NullpoMinoSlick.propGlobal.setProperty("name.mode." + strCurrentFolder, list[cursor]); } NullpoMinoSlick.propGlobal.setProperty("name.mode", list[cursor]); NullpoMinoSlick.saveConfig(); game.enterState(StateSelectRuleFromList.ID); } return false; }
Example #5
Source File: BlobbyTransition.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.state.transition.Transition#preRender(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void preRender(StateBasedGame game, GameContainer container, Graphics g) throws SlickException { prev.render(container, game, g); MaskUtil.defineMask(); for (int i=0;i<blobs.size();i++) { ((Blob) blobs.get(i)).render(g); } MaskUtil.finishDefineMask(); MaskUtil.drawOnMask(); if (background != null) { Color c = g.getColor(); g.setColor(background); g.fillRect(0,0,container.getWidth(),container.getHeight()); g.setColor(c); } }
Example #6
Source File: BlobbyTransition.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.state.transition.Transition#update(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, int) */ public void update(StateBasedGame game, GameContainer container, int delta) throws SlickException { if (blobs.size() == 0) { for (int i=0;i<blobCount;i++) { blobs.add(new Blob(container)); } } for (int i=0;i<blobs.size();i++) { ((Blob) blobs.get(i)).update(delta); } timer -= delta; if (timer < 0) { finish = true; } }
Example #7
Source File: BaseGameState.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Draw the screen. BaseGameState will do the common things (such as Framerate Cap or Screen Shot) here. * Your code will be in renderImpl, unless if you want do something special. */ public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { // Lost the focus if(!container.hasFocus()) { if(!NullpoMinoSlick.alternateFPSTiming) NullpoMinoSlick.alternateFPSSleep(); return; } // Do user's code renderImpl(container, game, g); // Do common things NullpoMinoSlick.drawFPS(container); // FPS counter NullpoMinoSlick.drawObserverClient(); // Observer if(screenShotFlag) { // Create a screenshot NullpoMinoSlick.saveScreenShot(container, g); screenShotFlag = false; } // Framerate Cap if(!NullpoMinoSlick.alternateFPSTiming) NullpoMinoSlick.alternateFPSSleep(); }
Example #8
Source File: BaseGameState.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Update the game. BaseGameState will do the common things (such as Framerate Cap or Screen Shot) here. * Your code will be in updateImpl, unless if you want do something special. */ public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { // Lost the focus if(!container.hasFocus()) { GameKeySlick.gamekey[0].clear(); GameKeySlick.gamekey[1].clear(); if(NullpoMinoSlick.alternateFPSTiming) NullpoMinoSlick.alternateFPSSleep(); return; } // Do user's code updateImpl(container, game, delta); // Screenshot button if(GameKeySlick.gamekey[0].isPushKey(GameKeySlick.BUTTON_SCREENSHOT)) screenShotFlag = true; // Exit button if(GameKeySlick.gamekey[0].isPushKey(GameKeySlick.BUTTON_QUIT)) container.exit(); // Framerate Cap if(NullpoMinoSlick.alternateFPSTiming) NullpoMinoSlick.alternateFPSSleep(); }
Example #9
Source File: ButtonMenu.java From opsu with GNU General Public License v3.0 | 6 votes |
/** * Processes a state enter request. * @param container the game container * @param game the game */ public void enter(GameContainer container, StateBasedGame game) { float center = container.getWidth() / 2f; float centerOffsetX = container.getWidth() * OFFSET_WIDTH_RATIO; centerOffset = new AnimatedValue(700, centerOffsetX, 0, AnimationEquation.OUT_BOUNCE); for (int i = 0; i < buttons.length; i++) { menuButtons[i].setX(center + ((i % 2 == 0) ? centerOffsetX : centerOffsetX * -1)); menuButtons[i].resetHover(); } // create title string list actualTitle = new ArrayList<String>(); String[] title = getTitle(container, game); int maxLineWidth = (int) (container.getWidth() * 0.96f); for (int i = 0; i < title.length; i++) { // wrap text if too long if (Fonts.LARGE.getWidth(title[i]) > maxLineWidth) { List<String> list = Fonts.wrap(Fonts.LARGE, title[i], maxLineWidth, false); actualTitle.addAll(list); } else actualTitle.add(title[i]); } }
Example #10
Source File: StateConfigAISelect.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void renderImpl(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { // Background g.drawImage(ResourceHolderSlick.imgMenu, 0, 0); // Menu NormalFontSlick.printFontGrid(1, 1, (player + 1) + "P AI SETTING", NormalFontSlick.COLOR_ORANGE); NormalFontSlick.printFontGrid(1, 3 + cursor, "b", NormalFontSlick.COLOR_RED); String aiName = ""; if(aiID < 0) aiName = "(DISABLE)"; else aiName = aiNameList[aiID].toUpperCase(); NormalFontSlick.printFontGrid(2, 3, "AI TYPE:" + aiName, (cursor == 0)); NormalFontSlick.printFontGrid(2, 4, "AI MOVE DELAY:" + aiMoveDelay, (cursor == 1)); NormalFontSlick.printFontGrid(2, 5, "AI THINK DELAY:" + aiThinkDelay, (cursor == 2)); NormalFontSlick.printFontGrid(2, 6, "AI USE THREAD:" + GeneralUtil.getONorOFF(aiUseThread), (cursor == 3)); NormalFontSlick.printFontGrid(2, 7, "AI SHOW HINT:" + GeneralUtil.getONorOFF(aiShowHint), (cursor == 4)); NormalFontSlick.printFontGrid(2, 8, "AI PRE-THINK:" + GeneralUtil.getONorOFF(aiPrethink), (cursor == 5)); NormalFontSlick.printFontGrid(2, 9, "AI SHOW INFO:" + GeneralUtil.getONorOFF(aiShowState), (cursor == 6)); NormalFontSlick.printFontGrid(1, 28, "A:OK B:CANCEL", NormalFontSlick.COLOR_GREEN); }
Example #11
Source File: StateConfigKeyboard.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { if(!container.hasFocus()) { if(NullpoMinoSlick.alternateFPSTiming) NullpoMinoSlick.alternateFPSSleep(); return; } frame++; if(keyConfigRestFrame > 0) keyConfigRestFrame--; // JInput if(NullpoMinoSlick.useJInputKeyboard) { JInputManager.poll(); if(frame >= KEYACCEPTFRAME) { for(int i = 0; i < JInputManager.MAX_SLICK_KEY; i++) { if(JInputManager.isKeyDown(i)) { onKey(i); frame = 0; break; } } } } if(NullpoMinoSlick.alternateFPSTiming) NullpoMinoSlick.alternateFPSSleep(); }
Example #12
Source File: StateConfigKeyboardNavi.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected boolean onDecide(GameContainer container, StateBasedGame game, int delta) { if (cursor == 0) { for(int i = 0; i < GameKeySlick.MAX_BUTTON; i++) { GameKeySlick.gamekey[player].keymapNav[i] = GameKeySlick.gamekey[player].keymap[i]; } } else if (cursor == 1) { NullpoMinoSlick.stateConfigKeyboard.player = player; NullpoMinoSlick.stateConfigKeyboard.isNavSetting = true; game.enterState(StateConfigKeyboard.ID); return true; } GameKeySlick.gamekey[player].saveConfig(NullpoMinoSlick.propConfig); NullpoMinoSlick.saveConfig(); ResourceHolderSlick.soundManager.play("decide"); gameObj.enterState(StateConfigMainMenu.ID); return true; }
Example #13
Source File: StateConfigJoystickTest.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { if(!container.hasFocus()) { if(NullpoMinoSlick.alternateFPSTiming) NullpoMinoSlick.alternateFPSSleep(); return; } frame++; // Joystick button if(frame >= KEYACCEPTFRAME) { for(int i = 0; i < buttonCount; i++) { try { if(ControllerManager.isControllerButton(player, container.getInput(), i)) { ResourceHolderSlick.soundManager.play("change"); lastPressButton = i; } } catch (Throwable e) {} } } // JInput if(NullpoMinoSlick.useJInputKeyboard) { JInputManager.poll(); if(frame >= KEYACCEPTFRAME) { for(int i = 0; i < JInputManager.MAX_SLICK_KEY; i++) { if(JInputManager.isKeyDown(i)) { onKey(i); break; } } } } if(NullpoMinoSlick.alternateFPSTiming) NullpoMinoSlick.alternateFPSSleep(); }
Example #14
Source File: StateNetGame.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void enter(GameContainer container, StateBasedGame game) throws SlickException { // Init variables showbg = NullpoMinoSlick.propConfig.getProperty("option.showbg", true); prevInGameFlag = false; // Observer stop NullpoMinoSlick.stopObserverClient(); // 60FPS NullpoMinoSlick.altMaxFPS = 60; appContainer.setAlwaysRender(true); appContainer.setUpdateOnlyWhenVisible(false); // Clear each frame appContainer.setClearEachFrame(!showbg); // gameManager initialization gameManager = new GameManager(new RendererSlick()); gameManager.receiver.setGraphics(appContainer.getGraphics()); // Lobby initialization netLobby = new NetLobbyFrame(); netLobby.addListener(this); // Mode initialization enterNewMode(null); // Lobby start netLobby.init(); netLobby.setVisible(true); }
Example #15
Source File: StateConfigKeyboardNavi.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void renderImpl(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { g.drawImage(ResourceHolderSlick.imgMenu, 0, 0); NormalFontSlick.printFontGrid(1, 1, "KEYBOARD NAVIGATION SETTING (" + (player + 1) + "P)", NormalFontSlick.COLOR_ORANGE); NormalFontSlick.printFontGrid(1, 3 + cursor, "b", NormalFontSlick.COLOR_RED); NormalFontSlick.printFontGrid(2, 3, "COPY FROM GAME KEYS", (cursor == 0)); NormalFontSlick.printFontGrid(2, 4, "CUSTOMIZE", (cursor == 1)); }
Example #16
Source File: ButtonMenu.java From opsu with GNU General Public License v3.0 | 5 votes |
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUHIT); Utils.copyToClipboard(ErrorHandler.getEnvironmentInfoForIssue()); UI.getNotificationManager().sendNotification("Debug info copied to clipboard."); game.enterState(Opsu.STATE_MAINMENU, new EmptyTransition(), new FadeInTransition()); }
Example #17
Source File: ButtonMenu.java From opsu with GNU General Public License v3.0 | 5 votes |
@Override public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { UI.update(delta); MusicController.loopTrackIfEnded(false); if (menuState != null) menuState.update(container, delta, input.getMouseX(), input.getMouseY()); }
Example #18
Source File: HorizontalSplitTransition.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.state.transition.Transition#update(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, int) */ public void update(StateBasedGame game, GameContainer container, int delta) throws SlickException { offset += delta * 1f; if (offset > container.getWidth() / 2) { finish = true; } }
Example #19
Source File: ButtonMenu.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Processes a mouse click action. * @param container the game container * @param game the game * @param cx the x coordinate * @param cy the y coordinate */ public void click(GameContainer container, StateBasedGame game, int cx, int cy) { for (int i = 0; i < buttons.length; i++) { if (menuButtons[i].contains(cx, cy)) { buttons[i].click(container, game); break; } } }
Example #20
Source File: SelectTransition.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.state.transition.Transition#postRender(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void postRender(StateBasedGame game, GameContainer container, Graphics g) throws SlickException { g.resetTransform(); if (!moveBackDone) { g.translate(xp1,yp1); g.scale(scale1, scale1); g.setClip((int) xp1,(int) yp1,(int) (scale1*container.getWidth()),(int) (scale1*container.getHeight())); prev.render(container, game, g); g.resetTransform(); g.clearClip(); } }
Example #21
Source File: StateConfigAISelect.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void enter(GameContainer container, StateBasedGame game) throws SlickException { currentAI = NullpoMinoSlick.propGlobal.getProperty(player + ".ai", ""); aiMoveDelay = NullpoMinoSlick.propGlobal.getProperty(player + ".aiMoveDelay", 0); aiThinkDelay = NullpoMinoSlick.propGlobal.getProperty(player + ".aiThinkDelay", 0); aiUseThread = NullpoMinoSlick.propGlobal.getProperty(player + ".aiUseThread", true); aiShowHint = NullpoMinoSlick.propGlobal.getProperty(player+ ".aiShowHint", false); aiPrethink = NullpoMinoSlick.propGlobal.getProperty(player+ ".aiPrethink", false); aiShowState = NullpoMinoSlick.propGlobal.getProperty(player+ ".aiShowState", false); aiID = -1; for(int i = 0; i < aiPathList.length; i++) { if(currentAI.equals(aiPathList[i])) aiID = i; } }
Example #22
Source File: GamePauseMenu.java From opsu with GNU General Public License v3.0 | 5 votes |
@Override public void init(GameContainer container, StateBasedGame game) throws SlickException { this.container = container; this.game = game; this.input = container.getInput(); this.gameState = (Game) game.getState(Opsu.STATE_GAME); }
Example #23
Source File: Game.java From opsu with GNU General Public License v3.0 | 5 votes |
@Override public void leave(GameContainer container, StateBasedGame game) throws SlickException { // container.setMouseGrabbed(false); // re-hide cursor if (GameMod.AUTO.isActive() || isReplay) UI.getCursor().hide(); // replays if (isReplay) GameMod.loadModState(previousMods); }
Example #24
Source File: StateConfigGameTuning.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void init(GameContainer container, StateBasedGame game) throws SlickException { if(container instanceof AppGameContainer) { appContainer = (AppGameContainer)container; } else { log.error("This container isn't AppGameContainer"); } }
Example #25
Source File: Splash.java From opsu with GNU General Public License v3.0 | 5 votes |
@Override public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { g.setBackground(Color.black); GameImage.MENU_LOGO.getImage().drawCentered(container.getWidth() / 2, container.getHeight() / 2); UI.drawLoadingProgress(g, Options.isLoadVerbose() ? 1f : progressAlpha.getValue()); }
Example #26
Source File: CombinedTransition.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.state.transition.Transition#update(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, int) */ public void update(StateBasedGame game, GameContainer container, int delta) throws SlickException { for (int i=0;i<transitions.size();i++) { Transition t = (Transition) transitions.get(i); if (!t.isComplete()) { t.update(game, container, delta); } } }
Example #27
Source File: FadeOutTransition.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.state.transition.Transition#postRender(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void postRender(StateBasedGame game, GameContainer container, Graphics g) { Color old = g.getColor(); g.setColor(color); g.fillRect(0, 0, container.getWidth() * 2, container.getHeight() * 2); g.setColor(old); }
Example #28
Source File: ButtonMenu.java From opsu with GNU General Public License v3.0 | 5 votes |
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUCLICK); for (GameMod mod : GameMod.values()) { if (mod.isActive()) mod.toggle(false); } }
Example #29
Source File: StateConfigRuleSelect.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void onRenderSuccess (GameContainer container, StateBasedGame game, Graphics graphics) { String title = "SELECT " + (player + 1) + "P RULE (" + (cursor + 1) + "/" + (list.length) + ")"; NormalFontSlick.printFontGrid(1, 1, title, NormalFontSlick.COLOR_ORANGE); NormalFontSlick.printFontGrid(1, 25, "CURRENT:" + strCurrentRuleName.toUpperCase(), NormalFontSlick.COLOR_BLUE); NormalFontSlick.printFontGrid(9, 26, strCurrentFileName.toUpperCase(), NormalFontSlick.COLOR_BLUE); NormalFontSlick.printFontGrid(1, 28, "A:OK B:CANCEL D:TOGGLE-VIEW", NormalFontSlick.COLOR_GREEN); }
Example #30
Source File: StateConfigRuleStyleSelect.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void renderImpl(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { // Background g.drawImage(ResourceHolderSlick.imgMenu, 0, 0); // Menu NormalFontSlick.printFontGrid(1, 1, "SELECT " + (player+1) + "P STYLE", NormalFontSlick.COLOR_ORANGE); NormalFontSlick.printFontGrid(1, 3 + cursor, "b", NormalFontSlick.COLOR_RED); for(int i = 0; i < GameEngine.MAX_GAMESTYLE; i++) { NormalFontSlick.printFontGrid(2, 3 + i, GameEngine.GAMESTYLE_NAMES[i], (cursor == i)); } }