Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///Public Java Game Loop
- long lastTime = System.nanoTime();
- double amountOfTicks = 60.0;
- double ns = 1000000000 / amountOfTicks;
- double delta = 0;
- long timer = System.currentTimeMillis();
- int frames = 0;
- while (running) {
- long now = System.nanoTime();
- delta += (now - lastTime) / ns;
- lastTime = now;
- while (delta >= 1) {
- tick();
- delta--;
- }
- if (running) render();
- frames++;
- if (System.currentTimeMillis() - timer > 1000) {
- timer += 1000;
- System.out.println("FPS: "+frames);
- frames = 0;
- }
- }
- stop();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement