org.newdawn.slick.SlickException Java Examples
The following examples show how to use
org.newdawn.slick.SlickException.
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: GamePauseMenu.java From opsu with GNU General Public License v3.0 | 6 votes |
@Override public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { // get background image GameImage bg = (gameState.getPlayState() == Game.PlayState.LOSE) ? GameImage.FAIL_BACKGROUND : GameImage.PAUSE_OVERLAY; // don't draw default background if button skinned and background unskinned boolean buttonsSkinned = GameImage.PAUSE_CONTINUE.hasBeatmapSkinImage() || GameImage.PAUSE_RETRY.hasBeatmapSkinImage() || GameImage.PAUSE_BACK.hasBeatmapSkinImage(); if (!buttonsSkinned || bg.hasBeatmapSkinImage()) bg.getImage().drawCentered(container.getWidth() / 2, container.getHeight() / 2); else g.setBackground(Color.black); // draw buttons if (gameState.getPlayState() != Game.PlayState.LOSE) continueButton.draw(); retryButton.draw(); backButton.draw(); UI.draw(g); }
Example #2
Source File: ImageLoader.java From opsu-dance with GNU General Public License v3.0 | 6 votes |
/** * Loads the image. * @param threaded true to load the image data in a new thread */ public void load(boolean threaded) { if (!file.isFile()) return; if (threaded) { if (loaderThread != null && loaderThread.isAlive()) loaderThread.interrupt(); loaderThread = new ImageLoaderThread(); loaderThread.start(); } else { try { image = new Image(file.getAbsolutePath()); } catch (SlickException e) { Log.warn(String.format("Failed to load background image '%s'.", file), e); } } }
Example #3
Source File: Options.java From opsu with GNU General Public License v3.0 | 6 votes |
/** * Sets the container size and makes the window borderless if the container * size is identical to the screen resolution. * <p> * If the configured resolution is larger than the screen size, the smallest * available resolution will be used. * @param app the game container */ public static void setDisplayMode(Container app) { int screenWidth = app.getScreenWidth(); int screenHeight = app.getScreenHeight(); boolean fullscreen = isFullscreen(); // check for larger-than-screen dimensions if (screenWidth < resolution.getWidth() || screenHeight < resolution.getHeight()) resolution = Resolution.RES_800_600; // check if fullscreen mode is possible with this resolution if (fullscreen && !resolution.hasFullscreenDisplayMode()) fullscreen = false; try { app.setDisplayMode(resolution.getWidth(), resolution.getHeight(), fullscreen); } catch (SlickException e) { ErrorHandler.error("Failed to set display mode.", e, true); } // set borderless window if dimensions match screen size if (!fullscreen) { boolean borderless = (screenWidth == resolution.getWidth() && screenHeight == resolution.getHeight()); System.setProperty("org.lwjgl.opengl.Window.undecorated", Boolean.toString(borderless)); } }
Example #4
Source File: TexturePaintTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { poly.addPoint(120, 120); poly.addPoint(420, 100); poly.addPoint(620, 420); poly.addPoint(300, 320); image = new Image("testdata/rocks.png"); texPaint = new TexCoordGenerator() { public Vector2f getCoordFor(float x, float y) { float tx = (texRect.getX() - x) / texRect.getWidth(); float ty = (texRect.getY() - y) / texRect.getHeight(); return new Vector2f(tx,ty); } }; }
Example #5
Source File: ImageBufferEndianTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void init(GameContainer container) throws SlickException { // detect what endian we have if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) { endian = "Big endian"; } else if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) { endian = "Little endian"; } else endian = "no idea"; redImageBuffer = new ImageBuffer(100,100); fillImageBufferWithColor(redImageBuffer, Color.red, 100, 100); blueImageBuffer = new ImageBuffer(100,100); fillImageBufferWithColor(blueImageBuffer, Color.blue, 100, 100); fromRed = redImageBuffer.getImage(); fromBlue = blueImageBuffer.getImage(); }
Example #6
Source File: FontPerformanceTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.Game#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { font = new AngelCodeFont("testdata/perffont.fnt","testdata/perffont.png"); for (int j=0;j<2;j++) { int lineLen = 90; for (int i=0;i<text.length();i+=lineLen) { if (i+lineLen > text.length()) { lineLen = text.length() - i; } lines.add(text.substring(i, i+lineLen)); } lines.add(""); } }
Example #7
Source File: Scroller.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.BasicGame#update(org.newdawn.slick.GameContainer, int) */ public void update(GameContainer container, int delta) throws SlickException { // check the controls, left/right adjust the rotation of the tank, up/down // move backwards and forwards if (container.getInput().isKeyDown(Input.KEY_LEFT)) { ang -= delta * TANK_ROTATE_SPEED; updateMovementVector(); } if (container.getInput().isKeyDown(Input.KEY_RIGHT)) { ang += delta * TANK_ROTATE_SPEED; updateMovementVector(); } if (container.getInput().isKeyDown(Input.KEY_UP)) { if (tryMove(dirX * delta * TANK_MOVE_SPEED, dirY * delta * TANK_MOVE_SPEED)) { // if we managed to move update the animation player.update(delta); } } if (container.getInput().isKeyDown(Input.KEY_DOWN)) { if (tryMove(-dirX * delta * TANK_MOVE_SPEED, -dirY * delta * TANK_MOVE_SPEED)) { // if we managed to move update the animation player.update(delta); } } }
Example #8
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 #9
Source File: SoundTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { SoundStore.get().setMaxSources(32); myContainer = container; sound = new Sound("testdata/restart.ogg"); charlie = new Sound("testdata/cbrown01.wav"); try { engine = AudioLoader.getAudio("WAV", ResourceLoader.getResourceAsStream("testdata/engine.wav")); } catch (IOException e) { throw new SlickException("Failed to load engine", e); } music = musica = new Music("testdata/SMB-X.XM"); //music = musica = new Music("testdata/theme.ogg", true); musicb = new Music("testdata/kirby.ogg", true); burp = new Sound("testdata/burp.aif"); music.play(); }
Example #10
Source File: StateBasedGame.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public final void init(GameContainer container) throws SlickException { this.container = container; initStatesList(container); Iterator gameStates = states.values().iterator(); while (gameStates.hasNext()) { GameState state = (GameState) gameStates.next(); state.init(container, this); } if (currentState != null) { currentState.enter(container, this); } }
Example #11
Source File: GraphicsFactory.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Create an underlying graphics context for the given image * * @param image The image we want to render to * @return The graphics context created * @throws SlickException */ private static Graphics createGraphics(Image image) throws SlickException { init(); if (fbo) { try { return new FBOGraphics(image); } catch (Exception e) { fbo = false; Log.warn("FBO failed in use, falling back to PBuffer"); } } if (pbuffer) { if (pbufferRT) { return new PBufferGraphics(image); } else { return new PBufferUniqueGraphics(image); } } throw new SlickException("Failed to create offscreen buffer even though the card reports it's possible"); }
Example #12
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 #13
Source File: ShapeTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { shapes = new ArrayList(); rect = new Rectangle(10, 10, 100, 80); shapes.add(rect); roundRect = new RoundedRectangle(150, 10, 60, 80, 20); shapes.add(roundRect); ellipse = new Ellipse(350, 40, 50, 30); shapes.add(ellipse); circle = new Circle(470, 60, 50); shapes.add(circle); polygon = new Polygon(new float[]{550, 10, 600, 40, 620, 100, 570, 130}); shapes.add(polygon); keys = new boolean[256]; lastChar = new char[256]; createPoly(200,200); }
Example #14
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 #15
Source File: TileMapTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { map = new TiledMap("testdata/testmap.tmx","testdata"); // read some properties from map and layer mapName = map.getMapProperty("name", "Unknown map name"); monsterDifficulty = map.getLayerProperty(0, "monsters", "easy peasy"); nonExistingMapProperty = map.getMapProperty("zaphod", "Undefined map property"); nonExistingLayerProperty = map.getLayerProperty(1, "beeblebrox", "Undefined layer property"); // store the original tileid of layer 0 at 10, 10 originalTileID = map.getTileId(10, 10, 0); }
Example #16
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 #17
Source File: SongMenu.java From opsu with GNU General Public License v3.0 | 5 votes |
@Override public void leave(GameContainer container, StateBasedGame game) throws SlickException { search.setFocus(false); sortMenu.deactivate(); optionsOverlay.deactivate(); optionsOverlay.reset(); showOptionsOverlay = false; userOverlay.deactivate(); showUserOverlay = false; }
Example #18
Source File: SavedStateTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Entry point to our test * * @param argv The arguments passed in the test */ public static void main(String[] argv) { try { container = new AppGameContainer(new SavedStateTest()); container.setDisplayMode(800,600,false); container.start(); } catch (SlickException e) { e.printStackTrace(); } }
Example #19
Source File: CurveTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { container.getGraphics().setBackground(Color.white); curve = new Curve(p2,c2,c1,p1); poly = new Polygon(); poly.addPoint(500,200); poly.addPoint(600,200); poly.addPoint(700,300); poly.addPoint(400,300); }
Example #20
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 #21
Source File: ButtonMenu.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); if (menuState != null) menuState.draw(container, game, g); }
Example #22
Source File: StateConfigJoystickTest.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { if(!container.hasFocus()) { if(!NullpoMinoSlick.alternateFPSTiming) NullpoMinoSlick.alternateFPSSleep(); return; } ResourceHolderSlick.imgMenu.draw(0, 0); NormalFontSlick.printFontGrid(1, 1, "JOYSTICK INPUT TEST (" + (player + 1) + "P)", NormalFontSlick.COLOR_ORANGE); if(joyNumber < 0) { NormalFontSlick.printFontGrid(1, 3, "NO JOYSTICK", NormalFontSlick.COLOR_RED); } else if(frame >= KEYACCEPTFRAME) { NormalFontSlick.printFontGrid(1, 3, "JOYSTICK NUMBER:" + joyNumber, NormalFontSlick.COLOR_RED); NormalFontSlick.printFontGrid(1, 5, "LAST PRESSED BUTTON:" + ((lastPressButton == -1) ? "NONE" : String.valueOf(lastPressButton))); Controller controller = ControllerManager.controllers.get(joyNumber); NormalFontSlick.printFontGrid(1, 7, "AXIS X:" + controller.getXAxisValue()); NormalFontSlick.printFontGrid(1, 8, "AXIS Y:" + controller.getYAxisValue()); NormalFontSlick.printFontGrid(1, 10, "POV X:" + controller.getPovX()); NormalFontSlick.printFontGrid(1, 11, "POV Y:" + controller.getPovY()); } if(frame >= KEYACCEPTFRAME) { NormalFontSlick.printFontGrid(1, 23, "ENTER/BACKSPACE: EXIT", NormalFontSlick.COLOR_GREEN); } // FPS NullpoMinoSlick.drawFPS(container); // Observer NullpoMinoSlick.drawObserverClient(); if(!NullpoMinoSlick.alternateFPSTiming) NullpoMinoSlick.alternateFPSSleep(); }
Example #23
Source File: MusicListenerTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) throws SlickException { g.drawString("Press M to play music", 100, 100); g.drawString("Press S to stream music", 100, 150); if (musicEnded) { g.drawString("Music Ended", 100, 200); } if (musicSwapped) { g.drawString("Music Swapped", 100, 250); } }
Example #24
Source File: GameRanking.java From opsu with GNU General Public License v3.0 | 5 votes |
@Override public void leave(GameContainer container, StateBasedGame game) throws SlickException { this.data = null; if (MusicController.isTrackDimmed()) MusicController.toggleTrackDimmed(1f); SoundController.stopSound(SoundEffect.APPLAUSE); }
Example #25
Source File: InputTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { if (container instanceof AppGameContainer) { app = (AppGameContainer) container; } input = container.getInput(); x = 300; y = 300; }
Example #26
Source File: StateBasedTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Entry point to our test * * @param argv The arguments to pass into the test */ public static void main(String[] argv) { try { AppGameContainer container = new AppGameContainer(new StateBasedTest()); container.setDisplayMode(800,600,false); container.start(); } catch (SlickException e) { e.printStackTrace(); } }
Example #27
Source File: MusicListenerTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { music = new Music("testdata/restart.ogg", false); stream = new Music("testdata/restart.ogg", false); music.addListener(this); stream.addListener(this); }
Example #28
Source File: GeomUtilTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see BasicGame#update(GameContainer, int) */ public void update(GameContainer container, int delta) throws SlickException { if (container.getInput().isKeyPressed(Input.KEY_SPACE)) { dynamic = !dynamic; } if (container.getInput().isKeyPressed(Input.KEY_ENTER)) { union = !union; makeBoolean(); } if (container.getInput().isKeyPressed(Input.KEY_1)) { cut = circle; circle.setCenterX(xp); circle.setCenterY(yp); makeBoolean(); } if (container.getInput().isKeyPressed(Input.KEY_2)) { cut = rect; rect.setCenterX(xp); rect.setCenterY(yp); makeBoolean(); } if (container.getInput().isKeyPressed(Input.KEY_3)) { cut = star; star.setCenterX(xp); star.setCenterY(yp); makeBoolean(); } if (dynamic) { xp = container.getInput().getMouseX(); yp = container.getInput().getMouseY(); makeBoolean(); } }
Example #29
Source File: ImageBufferEndianTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Entry point to the test * * @param args The arguments passed into the test */ public static void main(String[] args) { try { AppGameContainer container = new AppGameContainer(new ImageBufferEndianTest()); container.setDisplayMode(800,600,false); container.start(); } catch (SlickException e) { e.printStackTrace(); } }
Example #30
Source File: ButtonMenu.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(); // initialize buttons Image button = GameImage.MENU_BUTTON_MID.getImage(); button = button.getScaledCopy(container.getWidth() / 2, button.getHeight()); Image buttonL = GameImage.MENU_BUTTON_LEFT.getImage(); Image buttonR = GameImage.MENU_BUTTON_RIGHT.getImage(); for (MenuState ms : MenuState.values()) ms.init(container, game, button, buttonL, buttonR); }