From 13924244e253fe628b6d8bfed4d9c36222928cb7 Mon Sep 17 00:00:00 2001 From: MrDev023 Date: Sun, 20 Sep 2015 22:32:25 +0200 Subject: [PATCH] Engine update --- VBO/src/mrdev023/gameengine/GameEngine.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/VBO/src/mrdev023/gameengine/GameEngine.java b/VBO/src/mrdev023/gameengine/GameEngine.java index 7f912db..4b12fda 100644 --- a/VBO/src/mrdev023/gameengine/GameEngine.java +++ b/VBO/src/mrdev023/gameengine/GameEngine.java @@ -27,7 +27,7 @@ public class GameEngine { public static GameState gameState = GameState.MAIN_MENU; public static void initWindow(){ - Main.mainPool = Executors.newWorkStealingPool(); + Main.mainPool = Executors.newWorkStealingPool(1); try { Display.setTitle(TITLE); Display.setDisplayMode(new DisplayMode(width, height)); @@ -56,12 +56,13 @@ public class GameEngine { DisplayManager.setDelta(current - previous); current2 = System.nanoTime(); - if (elapsed >= 1000 / 60) { + if ((float)elapsed >= 1000.0f / 60.0f) { + Display.processMessages(); Update.updateMouse(); Update.updateKeyboard(); Update.update(); TICKS++; - elapsed = 0; + elapsed -= (long)(1000.0f/60.0f); timeTicks = System.nanoTime() - current2; } else { DisplayManager.clearScreen(); @@ -71,6 +72,7 @@ public class GameEngine { DisplayManager.render2D(); FPS++; timeFps = System.nanoTime() - current2; + Display.update(false); } if (elapsedInfo >= 1000) { @@ -84,13 +86,14 @@ public class GameEngine { + Camera.getPosition().getZ() + " | " + World.updateWorldTime + " " + DisplayManager.getDelta() + " | " + + (int)((((float)Runtime.getRuntime().freeMemory()/1024.0)/((float)Runtime.getRuntime().totalMemory()/1024.0f))*100) + + "% free | " + Runtime.getRuntime().totalMemory()/1024); FPS = 0; TICKS = 0; elapsedInfo = 0; } - Display.update(); } destroy(); }