public void update(GameContainer container, int delta) throws SlickException { if (!paused) { ypos += delta * 0.002 * systemMove; if (ypos > 300) { ypos = -300; } if (ypos < -300) { ypos = 300; } for (int i = 0; i < emitters.size(); i++) { ((ConfigurableEmitter) emitters.get(i)).replayCheck(); } for (int i = 0; i < delta; i++) { system.update(1); } } Display.sync(100); }
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { this.container = container; sheet = new PackedSpriteSheet("testdata/testpack.def", Image.FILTER_NEAREST); rocket = sheet.getSprite("rocket"); SpriteSheet anim = sheet.getSpriteSheet("runner"); runner = new Animation(); for (int y=0;y<2;y++) { for (int x=0;x<6;x++) { runner.addFrame(anim.getSprite(x,y), 50); } } }
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) { if (nextResource != null) { g.drawString("Loading: "+nextResource.getDescription(), 100, 100); } int total = LoadingList.get().getTotalResources(); int loaded = LoadingList.get().getTotalResources() - LoadingList.get().getRemainingResources(); float bar = loaded / (float) total; g.fillRect(100,150,loaded*40,20); g.drawRect(100,150,total*40,20); if (started) { image.draw(100,200); font.drawString(100,500,"LOADING COMPLETE"); } }
/** * @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(); }
/** * Create a new state based game * * @param name The name of the game */ public StateBasedGame(String name) { this.title = name; currentState = new BasicGameState() { public int getID() { return -1; } public void init(GameContainer container, StateBasedGame game) throws SlickException { } public void render(StateBasedGame game, Graphics g) throws SlickException { } public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { } public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { } }; }
public void reset(GameContainer gc) throws SlickException{ time = 0L; accu = 0L; consoleTimer = 0L; Globals.player.reset(); entities.clear(); entities.put("enemyController", new EnemyController()); gameStarted = false; paused = false; consoleOpen = false; console = new Console(this, gc); hud = new HUD(); }
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { this.container = container; image = new Image("testdata/logo.tga", true); Image temp = new Image("testdata/palette_tool.png"); container.setMouseCursor(temp, 0, 0); container.setIcons(new String[] {"testdata/icon.tga"}); container.setTargetFrameRate(100); poly = new Polygon(); float len = 100; for (int x=0;x<360;x+=30) { if (len == 100) { len = 50; } else { len = 100; } poly.addPoint((float) FastTrig.cos(Math.toRadians(x)) * len, (float) FastTrig.sin(Math.toRadians(x)) * len); } }
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(); }
/** * Draw Pause button * @param gc GameContainer * @param g Graphics * @throws SlickException */ public static void showPauseButton(GameContainer gc, Graphics g) throws SlickException { pauseButton.draw(pauseButtonPosX, pauseButtonPosY, pauseButtonWidth, pauseButtonHeight); if (Controller.mouseInArea(pauseButtonPosX, pauseButtonPosY, pauseButtonPosX + pauseButtonHeight, pauseButtonPosY + pauseButtonHeight)) { pauseButton.draw(pauseButtonPosX, pauseButtonPosY, pauseButtonWidth, pauseButtonHeight, new Color(0, 0, 0, 50)); if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { gc.setPaused(!gc.isPaused()); try { TimeUnit.MILLISECONDS.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } } }
/** * @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 { 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(); } g.translate(xp2,yp2); g.scale(scale2, scale2); g.setClip((int) xp2,(int) yp2,(int) (scale2*container.getWidth()),(int) (scale2*container.getHeight())); }
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { this.container = container; try { fire = ParticleIO.loadConfiguredSystem("testdata/system.xml"); } catch (IOException e) { throw new SlickException("Failed to load particle systems", e); } copy = new Image(400,300); String[] formats = ImageOut.getSupportedFormats(); message = "Formats supported: "; for (int i=0;i<formats.length;i++) { message += formats[i]; if (i < formats.length - 1) { message += ","; } } }
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { this.container = container; SpriteSheet sheet = new SpriteSheet("testdata/homeranim.png", 36, 65); animation = new Animation(); for (int i=0;i<8;i++) { animation.addFrame(sheet.getSprite(i,0), 150); } limited = new Animation(); for (int i=0;i<8;i++) { limited.addFrame(sheet.getSprite(i,0), 150); } limited.stopAt(7); manual = new Animation(false); for (int i=0;i<8;i++) { manual.addFrame(sheet.getSprite(i,0), 150); } pingPong = new Animation(sheet, 0,0,7,0,true,150,true); pingPong.setPingPong(true); container.getGraphics().setBackground(new Color(0.4f,0.6f,0.6f)); }
/** * @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(); }
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) { g.drawString("Press space to toggle",10,50); if (flash) { image.draw(100,100); } else { image.drawFlash(100,100,image.getWidth(), image.getHeight(), new Color(1,0,1f,1f)); } }
/** * @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); }
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(final GameContainer container) throws SlickException { operations = new Runnable() { public void run() { for (int i=0;i<100;i++) { int c = i+100; container.getGraphics().setColor(new Color(c,c,c,c)); container.getGraphics().drawOval((i*5)+50,(i*3)+50,100,100); } } }; cached = new CachedRender(operations); }
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { poly.addPoint(100, 100); poly.addPoint(120, 100); poly.addPoint(120, 120); poly.addPoint(100, 120); image = new Image("testdata/rocks.png"); }
/** * @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; } }
/** * Show play button * @param gc GameContainer * @param g Graphics */ public static void showPlayButton(GameContainer gc, Graphics g) { if (gc.isPaused()) { g.setColor(new Color(1, 1, 1, 100)); g.fillRect(0, 0, PZGUI.getWidth(), PZGUI.getHeight()); gamePausedText.render((PZGUI.getWidth()/2 - 170) * PZGUI.getResolutionRateWidth(), 300 * PZGUI.getResolutionRateHeight(), "Game is Paused!"); playButton.draw(pauseButtonPosX, pauseButtonPosY, pauseButtonWidth, pauseButtonHeight); } }
/** * @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]); } }
/** * @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); }
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { poly = new Polygon(); poly.addPoint(300, 100); poly.addPoint(320, 200); poly.addPoint(350, 210); poly.addPoint(280, 250); poly.addPoint(300, 200); poly.addPoint(240, 150); }
/** * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) throws SlickException { g.setColor(Color.white); g.texture(poly, image); ShapeRenderer.texture(poly, image, texPaint); }
/** * @see org.newdawn.slick.BasicGame#update(org.newdawn.slick.GameContainer, int) */ public final void update(GameContainer container, int delta) throws SlickException { preUpdateState(container, delta); if (leaveTransition != null) { leaveTransition.update(this, container, delta); if (leaveTransition.isComplete()) { currentState.leave(container, this); GameState prevState = currentState; currentState = nextState; nextState = null; leaveTransition = null; currentState.enter(container, this); if (enterTransition != null) { enterTransition.init(currentState, prevState); } } else { return; } } if (enterTransition != null) { enterTransition.update(this, container, delta); if (enterTransition.isComplete()) { enterTransition = null; } else { return; } } currentState.update(container, this, delta); postUpdateState(container, delta); }
@Override public void init(GameContainer gc, StateBasedGame game) throws SlickException { assets = AssetManager.getManager(); gameStart = new MenuButton(new Pair<Float>(50.0f, (Globals.HEIGHT - 200.0f)), "Start Game"); credits = new MenuButton(new Pair<Float>(50.0f, (Globals.HEIGHT - 140.0f)), "Credits"); exit = new MenuButton(new Pair<Float>(50.0f, (Globals.HEIGHT - 80.0f)), "Exit"); }
/** * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) throws SlickException { g.setColor(Color.white); g.drawString("1 - No Clipping", 100, 10); g.drawString("2 - Screen Clipping", 100, 30); g.drawString("3 - World Clipping", 100, 50); if (world) { g.drawString("WORLD CLIPPING ENABLED", 200, 80); } if (clip) { g.drawString("SCREEN CLIPPING ENABLED", 200, 80); } g.rotate(400, 400, ang); if (world) { g.setWorldClip(350,302,100,196); } if (clip) { g.setClip(350,302,100,196); } g.setColor(Color.red); g.fillOval(300,300,200,200); g.setColor(Color.blue); g.fillRect(390,200,20,400); g.clearClip(); g.clearWorldClip(); }
/** * Initialise resources and the map data * * @param container the container the game is running in */ public void init(GameContainer container) throws SlickException { container.setShowFPS(false); try { dataMap = new DataMap("testdata/map.dat"); } catch (IOException e) { throw new SlickException("Failed to load map data", e); } builder = new NavMeshBuilder(); navMesh = builder.build(dataMap); System.out.println("Navmesh shapes: "+navMesh.getSpaceCount()); }
/** * SplashScreen render */ public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException { g.setAntiAlias(PZGUI.isAA()); showBackGround(); showLogo(); startButton(gc, sbg, g); //DebugTool.showMousePosition(g); }
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) { g.drawRect(0,0,image.getWidth(),image.getHeight()); image.draw(0,0); image.draw(500,0,200,100); scaleMe.draw(500,100,200,100); scaled.draw(400,500); Image flipped = scaled.getFlippedCopy(true, false); flipped.draw(520,500); Image flipped2 = flipped.getFlippedCopy(false, true); flipped2.draw(520,380); Image flipped3 = flipped2.getFlippedCopy(true, false); flipped3.draw(400,380); for (int i=0;i<3;i++) { subImage.draw(200+(i*30),300); } g.translate(500, 200); g.rotate(50, 50, rot); g.scale(0.3f,0.3f); image.draw(); g.resetTransform(); rotImage.setRotation(rot); rotImage.draw(100, 200); }
/** * @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 { ang += delta * 0.5f; if (ang > 500) { finish = true; } scale -= delta * 0.001f; if (scale < 0) { scale = 0; } }
@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)) { sbg.enterState(Application.GAME); } }
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { // force a 256 pixel limit for testing original = image = new BigImage("testdata/bigimage.tga", Image.FILTER_NEAREST, 512); sub = image.getSubImage(210,210,200,130); scaledSub = sub.getScaledCopy(2); image = image.getScaledCopy(0.3f); imageX = image.getFlippedCopy(true, false); imageY = imageX.getFlippedCopy(true, true); bigSheet = new SpriteSheet(original, 16, 16); }
/** * @see BasicGame#init(GameContainer) */ public void init(GameContainer container) throws SlickException { base = InkscapeLoader.load("testdata/svg/walk1.svg"); morph = new SVGMorph(base); morph.addStep(InkscapeLoader.load("testdata/svg/walk2.svg")); morph.addStep(InkscapeLoader.load("testdata/svg/walk3.svg")); morph.addStep(InkscapeLoader.load("testdata/svg/walk4.svg")); container.setVSync(true); }
/** * @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#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; }
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { sound = new Sound(ResourceLoader.getResource("testdata/restart.ogg")); charlie = new Sound(ResourceLoader.getResource("testdata/cbrown01.wav")); engine = new Sound(ResourceLoader.getResource("testdata/engine.wav")); //music = musica = new Music("testdata/SMB-X.XM"); music = musica = new Music(ResourceLoader.getResource("testdata/restart.ogg"), false); musicb = new Music(ResourceLoader.getResource("testdata/kirby.ogg"), false); burp = new Sound(ResourceLoader.getResource("testdata/burp.aif")); }