Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void run() {
- long lastTime = System.nanoTime();
- //in milis so i can make fps 1000 milis = 1 second
- long timer = System.currentTimeMillis();
- final double NS = 1000000000.0 / 60.0;
- double delta = 0;
- int frames = 0;
- int updates = 0;
- //from componet lets movement happen
- requestFocus();
- while(isRunning){
- long now = System.nanoTime();
- delta += (now - lastTime) / NS;
- lastTime = now;
- while(delta>= 1){
- update();
- updates++;
- delta--;
- }
- render();
- frames++;
- if(System.currentTimeMillis()- timer > 1000){
- timer += 1000;
- System.out.println(updates + " ups, " + frames + " fps");
- frame.setTitle(title + " | "+ updates + " ups, " + frames + " fps");
- updates = 0;
- frames = 0;
- }
- }
- stop();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement