Game update system now respects frame update time
Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
5e97719ccf
commit
31f9bb513b
@ -92,8 +92,8 @@ public class RabiClone{
|
||||
lastGameTime=System.nanoTime();
|
||||
|
||||
|
||||
while (dt>=(1/244d)*1000000000) {
|
||||
double updateMult = 1/244d;
|
||||
while (dt>=(1/244d)*1000000000l) {
|
||||
final double updateMult = 1/244d;
|
||||
handleGameControllers();
|
||||
|
||||
KeyBind.poll();
|
||||
@ -129,10 +129,14 @@ public class RabiClone{
|
||||
OBJ.remove(i--);
|
||||
}
|
||||
}
|
||||
dt-=(1/244d)*1000000000;
|
||||
dt-=(1/244d)*1000000000l;
|
||||
}
|
||||
if (dt<0) {
|
||||
dt=0;
|
||||
if (dt<(1/244d)*1000000000l) {
|
||||
lastReportedTime=System.currentTimeMillis();
|
||||
} else
|
||||
if (System.currentTimeMillis()-lastReportedTime>5000) {
|
||||
System.out.println("WARNING! Game is lagging behind! Frames Behind: "+(dt/((1/244d)*1000000000l)));
|
||||
lastReportedTime=System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -395,6 +395,7 @@ public class Player extends AnimatedObject{
|
||||
groundCollision=true;
|
||||
collisionOccured=true;
|
||||
state = State.IDLE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!collisionOccured) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user