Include delta game time in update loop

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
Nic0Nic0Nii 3 years ago
parent 86adda64b2
commit d65eb10ef1
  1. BIN
      bin/RabiClone.jar
  2. 8
      src/sig/RabiClone.java

Binary file not shown.

@ -25,10 +25,16 @@ public class RabiClone {
f.setVisible(true);
p.render();
long lastGameTime = System.nanoTime();
while (true) {
long timePassed = System.nanoTime()-lastGameTime;
lastGameTime=System.nanoTime();
if (KeyHeld(KeyEvent.VK_UP)) {
System.out.println("Up Held: "+UPCOUNT++);
System.out.println("Up Held: "+UPCOUNT+++" (+"+(float)(timePassed/1000000f)+"ms)");
}
}
}
private static Boolean KeyHeld(int key) {

Loading…
Cancel
Save