@@ -0,0 +1,1394 @@
+package com.betato.gamedisplay;%0A%0Apublic class GameLoop %7B%0A%09%0A%09private int targetFps = 60;%0A%09private int nanoFps = 1000000000 / targetFps;%0A%09private int targetUps = 60;%0A%09private int nanoUps = 1000000000 / targetUps;%0A%09%0A%09public boolean running = true;%0A%09%0A%09public GameLoop(int targetFps, int targetUps) %7B%0A%09%09this.targetFps = targetFps;%0A%09%09this.targetUps = targetUps;%0A%09%09nanoFps = 1000000000 / targetFps;%0A%09%09nanoUps = 1000000000 / targetUps;%0A%09%7D%0A%09%0A%09// Runs the GameLoop%0A%09public void run() %7B%0A%09%09long startTime = System.nanoTime();%0A%09%09long deltaFps = 0;%0A%09%09long deltaUps = 0;%0A%09%09long deltaDisplay = 0;%0A%09%09int framecount = 0;%0A%09%09int updatecount = 0;%0A%0A%09%09while (running) %7B%0A%09%09%09// Get current time%0A%09%09%09long currentTime = System.nanoTime();%0A%09%09%09// Get time since last loop%0A%09%09%09deltaFps += currentTime - startTime;%0A%09%09%09deltaUps += currentTime - startTime;%0A%09%09%09deltaDisplay += currentTime - startTime;%0A%0A%09%09%09// Set start time of this loop for use in next cycle%0A%09%09%09startTime = currentTime;%0A%0A%09%09%09// Render if target time has been reached%0A%09%09%09if (deltaFps %3E= nanoFps) %7B%0A%09%09%09%09// Render%0A%09%09%09%09%0A%09%09%09%09framecount++;%0A%09%09%09%09deltaFps = 0;%0A%09%09%09%7D%0A%0A%09%09%09// Update if target time has been reached%0A%09%09%09if (deltaUps %3E= nanoUps) %7B%0A%09%09%09%09// Update%0A%09%09%09%09%0A%09%09%09%09updatecount++;%0A%09%09%09%09deltaUps = 0;%0A%09%09%09%7D%0A%0A%09%09%09// Update fps and ups if one second has passed%0A%09%09%09if (deltaDisplay %3E= 1000000000) %7B%0A%09%09%09%09%0A%09%09%09%09framecount = 0;%0A%09%09%09%09updatecount = 0;%0A%09%09%09%09deltaDisplay = 0;%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add GameLoop