org.newdawn.slick.GameContainer Java Examples
The following examples show how to use
org.newdawn.slick.GameContainer.
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: RotateTransition.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 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.translate(container.getWidth()/2, container.getHeight()/2); g.scale(scale,scale); g.rotate(0, 0, ang); g.translate(-container.getWidth()/2, -container.getHeight()/2); if (background != null) { Color c = g.getColor(); g.setColor(background); g.fillRect(0,0,container.getWidth(),container.getHeight()); g.setColor(c); } prev.render(container, game, g); g.translate(container.getWidth()/2, container.getHeight()/2); g.rotate(0, 0, -ang); g.scale(1/scale,1/scale); g.translate(-container.getWidth()/2, -container.getHeight()/2); }
Example #2
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 #3
Source File: GradientImageTest.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 { this.container = container; image1 = new Image("testdata/grass.png"); image2 = new Image("testdata/rocks.png"); fill = new GradientFill(-64,0,new Color(1,1,1,1f),64,0,new Color(0,0,0,0)); shape = new Rectangle(336,236,128,128); poly = new Polygon(); poly.addPoint(320,220); poly.addPoint(350,200); poly.addPoint(450,200); poly.addPoint(480,220); poly.addPoint(420,400); poly.addPoint(400,390); }
Example #4
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 #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: 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 #7
Source File: InkscapeTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 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.scale(zoom,zoom); g.translate(x, y); g.scale(0.3f,0.3f); //renderer[0].render(g); g.scale(1/0.3f,1/0.3f); g.translate(400, 0); //renderer[1].render(g); g.translate(100, 300); g.scale(0.7f,0.7f); //renderer[2].render(g); g.scale(1/0.7f,1/0.7f); g.scale(0.5f,0.5f); g.translate(-1100, -380); renderer[3].render(g); g.scale(1/0.5f,1/0.5f); // g.translate(280, 100); // g.scale(0.5f,0.5f); // renderer[4].render(g); g.resetTransform(); }
Example #8
Source File: StateConfigRuleSelect.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"); RuleEntry entry = ruleEntries.get(cursor); if(style == 0) { NullpoMinoSlick.propGlobal.setProperty(player + ".rule", entry.filepath); NullpoMinoSlick.propGlobal.setProperty(player + ".rulefile", entry.filename); NullpoMinoSlick.propGlobal.setProperty(player + ".rulename", entry.rulename); } else { NullpoMinoSlick.propGlobal.setProperty(player + ".rule." + style, entry.filepath); NullpoMinoSlick.propGlobal.setProperty(player + ".rulefile." + style, entry.filename); NullpoMinoSlick.propGlobal.setProperty(player + ".rulename." + style, entry.rulename); } NullpoMinoSlick.saveConfig(); game.enterState(StateConfigRuleStyleSelect.ID); return true; }
Example #9
Source File: GradientImageTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) { g.drawString("R - Toggle Rotationg",10,50); g.drawImage(image1, 100, 236); g.drawImage(image2, 600, 236); g.translate(0, -150); g.rotate(400, 300, ang); g.texture(shape, image2); g.texture(shape, image1, fill); g.resetTransform(); g.translate(0, 150); g.rotate(400, 300, ang); g.texture(poly, image2); g.texture(poly, image1, fill); g.resetTransform(); }
Example #10
Source File: GradientTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) { g.rotate(400, 300, ang); g.fill(rect, gradient); g.fill(round, gradient); g.fill(poly, gradient2); g.fill(center, gradient4); g.setAntiAlias(true); g.setLineWidth(10); g.draw(round2, gradient2); g.setLineWidth(2); g.draw(poly, gradient); g.setAntiAlias(false); g.fill(center, gradient4); g.setAntiAlias(true); g.setColor(Color.black); g.draw(center); g.setAntiAlias(false); }
Example #11
Source File: DummyMenuScrollState.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void renderImpl(GameContainer container, StateBasedGame game, Graphics graphics) throws SlickException { // Background graphics.drawImage(ResourceHolderSlick.imgMenu, 0, 0); // Menu if(list == null) { NormalFontSlick.printFontGrid(1, 1, nullError, NormalFontSlick.COLOR_RED); } else if(list.length == 0) { NormalFontSlick.printFontGrid(1, 1, emptyError, NormalFontSlick.COLOR_RED); } else { if (cursor >= list.length) cursor = 0; if (cursor < minentry) minentry = cursor; int maxentry = minentry + pageHeight - 1; if (cursor >= maxentry) { maxentry = cursor; minentry = maxentry - pageHeight + 1; } drawMenuList(graphics); onRenderSuccess(container, game, graphics); } }
Example #12
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 #13
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); try { Desktop.getDesktop().browse(OpsuConstants.REPOSITORY_URI); } catch (Exception e) { UI.getNotificationManager().sendNotification("The web page could not be opened.", Color.red); } game.enterState(Opsu.STATE_MAINMENU, new EmptyTransition(), new FadeInTransition()); }
Example #14
Source File: StateSelectModeFolder.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected boolean onDecide(GameContainer container, StateBasedGame game, int delta) { ResourceHolderSlick.soundManager.play("decide"); if(cursor < listFolder.size()) { strCurrentFolder = list[cursor]; } else { strCurrentFolder = ""; } NullpoMinoSlick.propGlobal.setProperty("name.folder", strCurrentFolder); NullpoMinoSlick.saveConfig(); StateSelectMode.isTopLevel = false; game.enterState(StateSelectMode.ID); return false; }
Example #15
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 #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); ScoreData scoreData = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getScoreData(); ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.SCORE, scoreData); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition()); }
Example #17
Source File: ParticleGame.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void init(GameContainer container) throws SlickException { container.getInput().addListener(listener); container.setShowFPS(false); system = new ParticleSystem("org/newdawn/slick/data/particle.tga", 2000); system.setBlendingMode(ParticleSystem.BLEND_ADDITIVE); system.setRemoveCompletedEmitters(false); for (int i = 0; i < waiting.size(); i++) { system.addEmitter((ParticleEmitter) waiting.get(i)); } waiting.clear(); }
Example #18
Source File: ButtonMenu.java From opsu with GNU General Public License v3.0 | 5 votes |
@Override public void keyPress(GameContainer container, StateBasedGame game, int key, char c) { super.keyPress(container, game, key, c); for (GameMod mod : GameMod.values()) { if (key == mod.getKey()) { mod.toggle(true); break; } } }
Example #19
Source File: StateReplaySelect.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void enter(GameContainer container, StateBasedGame game) throws SlickException { list = getReplayFileList(); if (list != null) maxCursor = list.length-1; setReplayRuleAndModeList(); }
Example #20
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); BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode(); MenuState ms = (node.beatmapIndex == -1 || node.getBeatmapSet().size() == 1) ? MenuState.BEATMAP_DELETE_CONFIRM : MenuState.BEATMAP_DELETE_SELECT; ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).setMenuState(ms, node); game.enterState(Opsu.STATE_BUTTONMENU); }
Example #21
Source File: ImageReadTest.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 { image = new Image("testdata/testcard.png"); read[0] = image.getColor(0, 0); read[1] = image.getColor(30, 40); read[2] = image.getColor(55, 70); read[3] = image.getColor(80, 90); }
Example #22
Source File: ImageReadTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.BasicGame#update(org.newdawn.slick.GameContainer, int) */ public void update(GameContainer container, int delta) { int mx = container.getInput().getMouseX(); int my = container.getInput().getMouseY(); if ((mx >= 100) && (my >= 100) && (mx < 200) && (my < 200)) { read[4] = image.getColor(mx-100,my-100); } else { read[4] = Color.black; } read[5] = g.getPixel(mx, my); }
Example #23
Source File: ButtonMenu.java From opsu with GNU General Public License v3.0 | 5 votes |
@Override public void update(GameContainer container, int delta, int mouseX, int mouseY) { super.update(container, delta, mouseX, mouseY); GameMod hoverMod = null; for (GameMod mod : GameMod.values()) { mod.hoverUpdate(delta, mod.isActive()); if (hoverMod == null && mod.contains(mouseX, mouseY)) hoverMod = mod; } // tooltips if (hoverMod != null) UI.updateTooltip(delta, hoverMod.getDescription(), true); }
Example #24
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); }
Example #25
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 #26
Source File: StateConfigRuleStyleSelect.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected boolean onDecide(GameContainer container, StateBasedGame game, int delta) { ResourceHolderSlick.soundManager.play("decide"); NullpoMinoSlick.stateConfigRuleSelect.player = player; NullpoMinoSlick.stateConfigRuleSelect.style = cursor; game.enterState(StateConfigRuleSelect.ID); return false; }
Example #27
Source File: GUITest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) { background.draw(0, 0, 800, 500); for (int i=0;i<4;i++) { areas[i].render(container, g); } field.render(container, g); field2.render(container, g); g.setFont(font); g.drawString(message, 200, 550); }
Example #28
Source File: EasedFadeOutTransition.java From opsu with GNU General Public License v3.0 | 5 votes |
@Override 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 #29
Source File: Circle.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Initializes the Circle data type with map modifiers, images, and dimensions. * @param container the game container * @param circleDiameter the circle diameter */ public static void init(GameContainer container, float circleDiameter) { diameter = circleDiameter * HitObject.getXMultiplier(); // convert from Osupixels (640x480) int diameterInt = (int) diameter; GameImage.HITCIRCLE.setImage(GameImage.HITCIRCLE.getImage().getScaledCopy(diameterInt, diameterInt)); GameImage.HITCIRCLE_OVERLAY.setImage(GameImage.HITCIRCLE_OVERLAY.getImage().getScaledCopy(diameterInt, diameterInt)); GameImage.APPROACHCIRCLE.setImage(GameImage.APPROACHCIRCLE.getImage().getScaledCopy(diameterInt, diameterInt)); }
Example #30
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); }