private void sync() { float loopSlot = 1f / TARGET_FPS; double endTime = timer.getLastLoopTime() + loopSlot; while (timer.getTime() < endTime) { try { Thread.sleep(1); } catch (InterruptedException ie) { } } }
public GameEngine(String windowTitle, int width, int height, boolean vSync, IGameLogic gameLogic) throws Exception { gameLoopThread = new Thread(this, "GAME_LOOP_THREAD"); window = new Window(windowTitle, width, height, vSync); this.gameLogic = gameLogic; timer = new Timer(); }
protected void init() throws Exception { window.init(); timer.init(); gameLogic.init(window); }
public float getElapsedTime() { double time = getTime(); float elapsedTime = (float) (time - lastLoopTime); lastLoopTime = time; return elapsedTime; }
protected void render() { if ( window.getWindowOptions().showFps && timer.getLastLoopTime() - lastFps > 1 ) { lastFps = timer.getLastLoopTime(); window.setWindowTitle(windowTitle + " - " + fps + " FPS"); fps = 0; } fps++; gameLogic.render(window); window.update(); }
public GameEngine(String windowTitle, int width, int height, boolean vSync, IGameLogic gameLogic) throws Exception { gameLoopThread = new Thread(this, "GAME_LOOP_THREAD"); window = new Window(windowTitle, width, height, vSync); this.gameLogic = gameLogic; timer = new Timer(); }
protected void init() throws Exception { window.init(); timer.init(); gameLogic.init(); }
public float getElapsedTime() { double time = getTime(); float elapsedTime = (float) (time - lastLoopTime); lastLoopTime = time; return elapsedTime; }
protected void render() { if ( window.getWindowOptions().showFps && timer.getLastLoopTime() - lastFps > 1 ) { lastFps = timer.getLastLoopTime(); window.setWindowTitle(windowTitle + " - " + fps + " FPS"); fps = 0; } fps++; gameLogic.render(window); window.update(); }
private void sync() { float loopSlot = 1f / TARGET_FPS; double endTime = timer.getLastLoopTime() + loopSlot; while (timer.getTime() < endTime) { try { Thread.sleep(1); } catch (InterruptedException ie) { } } }
public GameEngine(String windowTitle, int width, int height, boolean vSync, IGameLogic gameLogic) throws Exception { gameLoopThread = new Thread(this, "GAME_LOOP_THREAD"); window = new Window(windowTitle, width, height, vSync); this.gameLogic = gameLogic; timer = new Timer(); }
protected void init() throws Exception { window.init(); timer.init(); gameLogic.init(window); }
public float getElapsedTime() { double time = getTime(); float elapsedTime = (float) (time - lastLoopTime); lastLoopTime = time; return elapsedTime; }
private void sync() { float loopSlot = 1f / TARGET_FPS; double endTime = timer.getLastLoopTime() + loopSlot; while (timer.getTime() < endTime) { try { Thread.sleep(1); } catch (InterruptedException ie) { } } }
public GameEngine(String windowTitle, int width, int height, boolean vSync, IGameLogic gameLogic) throws Exception { gameLoopThread = new Thread(this, "GAME_LOOP_THREAD"); window = new Window(windowTitle, width, height, vSync); this.gameLogic = gameLogic; timer = new Timer(); }
protected void init() throws Exception { window.init(); timer.init(); mouseInput.init(window); gameLogic.init(window); }