Timing of loop is now based on accumulated time
Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
d6b17fce95
commit
5e97719ccf
Binary file not shown.
@ -84,14 +84,16 @@ public class RabiClone{
|
||||
p.render();
|
||||
|
||||
long lastGameTime = System.nanoTime();
|
||||
long dt = 0;
|
||||
|
||||
CONTROLLERS = ControllerEnvironment.getDefaultEnvironment().getControllers();
|
||||
while (true) {
|
||||
long timePassed = System.nanoTime()-lastGameTime;
|
||||
dt += System.nanoTime()-lastGameTime;
|
||||
lastGameTime=System.nanoTime();
|
||||
double updateMult = Math.min(1/120d,timePassed/1000000000d);
|
||||
|
||||
|
||||
while (dt>=(1/244d)*1000000000) {
|
||||
double updateMult = 1/244d;
|
||||
handleGameControllers();
|
||||
|
||||
KeyBind.poll();
|
||||
@ -127,6 +129,11 @@ public class RabiClone{
|
||||
OBJ.remove(i--);
|
||||
}
|
||||
}
|
||||
dt-=(1/244d)*1000000000;
|
||||
}
|
||||
if (dt<0) {
|
||||
dt=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user