Guest User

Untitled

a guest
Feb 21st, 2014
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. long lastTime = System.nanoTime();
  2. long timer = System.currentTimeMillis();
  3. final double ns = 1000000000.0 / ups;
  4. double delta = 0;
  5. int frames = 0;
  6. int updates = 0;
  7.  
  8. running = true;
  9.  
  10. while(running){
  11. long now = System.nanoTime();
  12. delta += (now-lastTime) / ns;
  13. lastTime = now;
  14. while (delta >= 1){
  15. update();
  16. updates++;
  17. delta--;
  18. }
  19.  
  20. frames++;
  21.  
  22. if (System.currentTimeMillis() - timer > 1000){
  23. timer += 1000;
  24. frame.setTitle( " | " + updates + " ups, " + frames + " fps");
  25. updates = 0;
  26. frames = 0;
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment