public void render(SpriteBatch batch) { super.render(batch); field.render(batch, fadeMultiplier); field2.render(batch, fadeMultiplier); probState.render(batch, fadeMultiplier); }
/** * Renders (draws) the whole screen, and then flips the double buffer, so that the newly rendered * screen is visible. * * @priority 3 */ public static void render() { try { currentGame.render(Video.getDisplaySurface()); } catch (Exception e) { handleException(e); } Video.flip(); }
public void start() { while (!has_won() { input.check_input(); if (doors[0].used()) { System.out.println("Not this one."); } Game.render(); } Game.load_next_level(); }
public void run() { while (gameRunning) { car.tick(); trafficCar.trafficUpdate(); render(globalGraphics); try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } } drawScore(globalGraphics); }
/** * Update and render the game * * @param delta The change in time since last update and render * @throws SlickException Indicates an internal fault to the game. */ protected void updateAndRender(int delta) throws SlickException { storedDelta += delta; input.poll(width, height); SoundStore.get().poll(delta); if (storedDelta >= minimumLogicInterval) { try { if (maximumLogicInterval != 0) { long cycles = storedDelta / maximumLogicInterval; for (int i = 0; i < cycles; i++) { game.update(this, (int) maximumLogicInterval); } game.update(this, (int) (delta % maximumLogicInterval)); } else { game.update(this, (int) storedDelta); } storedDelta = 0; } catch (Throwable e) { Log.error(e); throw new SlickException("Game.update() failure - check the game code."); } } GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glLoadIdentity(); graphics.resetFont(); graphics.resetLineWidth(); graphics.setAntiAlias(false); try { game.render(this, graphics); } catch (Throwable e) { Log.error(e); throw new SlickException("Game.render() failure - check the game code."); } graphics.resetTransform(); if (showFPS) { defaultFont.drawString(10, 10, "FPS: " + recordedFPS); } if (targetFPS != -1) { Display.sync(targetFPS); } }
public void run() { init(); long lastTime = System.nanoTime(); final double amountOfTicks = 60D; double ns = 1_000_000_000 / amountOfTicks; double delta = 0; while (running) { long now = System.nanoTime(); delta += (now - lastTime) / ns; lastTime = now; // only update 60 times per second if (delta >= 1) { tick(); delta--; } // draw all objects onto screen render(); } }
/** * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public final void render(GameContainer container, Graphics g) throws SlickException { int yoffset = 0; int xoffset = 0; if (targetHeight < container.getHeight()) { yoffset = (container.getHeight() - targetHeight) / 2; } if (targetWidth < container.getWidth()) { xoffset = (container.getWidth() - targetWidth) / 2; } SlickCallable.enterSafeBlock(); g.setClip(xoffset, yoffset, targetWidth, targetHeight); GL.glTranslatef(xoffset, yoffset, 0); g.scale(targetWidth / normalWidth, targetHeight / normalHeight); GL.glPushMatrix(); held.render(container, g); GL.glPopMatrix(); g.clearClip(); SlickCallable.leaveSafeBlock(); renderOverlay(container, g); }
public void render(ShapeRenderer sRender) { super.render(sRender); field.render(sRender, fadeMultiplier); field2.render(sRender, fadeMultiplier); }
/** * Update and render the game * * @param delta The change in time since last update and render * @throws SlickException Indicates an internal fault to the game. */ protected void updateAndRender(int delta) throws SlickException { if (smoothDeltas) { if (getFPS() != 0) { delta = 1000 / getFPS(); } } input.poll(width, height); Music.poll(delta); if (!paused) { storedDelta += delta; if (storedDelta >= minimumLogicInterval) { try { if (maximumLogicInterval != 0) { long cycles = storedDelta / maximumLogicInterval; for (int i = 0; i < cycles; i++) { game.update(this, (int) maximumLogicInterval); } int remainder = (int) (storedDelta % maximumLogicInterval); if (remainder > minimumLogicInterval) { game.update(this, (int) (remainder % maximumLogicInterval)); storedDelta = 0; } else { storedDelta = remainder; } } else { game.update(this, (int) storedDelta); storedDelta = 0; } } catch (Throwable e) { // Log.error(e); throw new SlickException("Game.update() failure.", e); } } } else { game.update(this, 0); } if (hasFocus() || getAlwaysRender()) { if (clearEachFrame) { GL.glClear(SGL.GL_COLOR_BUFFER_BIT | SGL.GL_DEPTH_BUFFER_BIT); } GL.glLoadIdentity(); graphics.resetTransform(); graphics.resetFont(); graphics.resetLineWidth(); graphics.setAntiAlias(false); try { game.render(this, graphics); } catch (Throwable e) { // Log.error(e); throw new SlickException("Game.render() failure.", e); } graphics.resetTransform(); if (showFPS) { defaultFont.drawString(10, 10, "FPS: " + recordedFPS); } GL.flush(); } if (targetFPS != -1) { Display.sync(targetFPS); } }