Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- long lastTime = System.nanoTime();
- long timer = System.currentTimeMillis();
- final double ns = 1000000000.0 / ups;
- double delta = 0;
- int frames = 0;
- int updates = 0;
- running = true;
- while(running){
- long now = System.nanoTime();
- delta += (now-lastTime) / ns;
- lastTime = now;
- while (delta >= 1){
- update();
- updates++;
- delta--;
- }
- frames++;
- if (System.currentTimeMillis() - timer > 1000){
- timer += 1000;
- frame.setTitle( " | " + updates + " ups, " + frames + " fps");
- updates = 0;
- frames = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment