Sleepi_

thing2

Aug 28th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1.     public void startGameLoop(){
  2.         long initialTime = System.nanoTime();
  3.         double ns = 1000000000 / TPS;
  4.         double delta = 0;
  5.         int fps = 0;
  6.         while(true){ //Game loop:
  7.             long now = System.nanoTime();
  8.             delta += (now - initialTime) / ns;
  9.             initialTime = now;
  10.             while(delta >= 1){
  11.                 tick();
  12.                 fpsTimer.tick();
  13.                 if(fpsTimer.isActivatedThisTick()){
  14.                     currentFPS = fps;
  15.                     fps = 0;
  16.                 }
  17.                 delta--;
  18.             }
  19.             render();
  20.             fps++;
  21.         }
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment