Include delta game time in update loop
Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
86adda64b2
commit
d65eb10ef1
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…
x
Reference in New Issue
Block a user