Game update loop runs at a set rate.
Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
a3a2c62d4b
commit
8a46cb56a6
Binary file not shown.
@ -90,7 +90,7 @@ public class RabiClone{
|
|||||||
while (true) {
|
while (true) {
|
||||||
long timePassed = System.nanoTime()-lastGameTime;
|
long timePassed = System.nanoTime()-lastGameTime;
|
||||||
lastGameTime=System.nanoTime();
|
lastGameTime=System.nanoTime();
|
||||||
double updateMult = Math.min(1/120d,timePassed/1000000000d);
|
double updateMult = 1/60d;
|
||||||
|
|
||||||
|
|
||||||
handleGameControllers();
|
handleGameControllers();
|
||||||
|
@ -21,8 +21,13 @@ public class String{
|
|||||||
this.sb=new StringBuilder(Double.toString(d));
|
this.sb=new StringBuilder(Double.toString(d));
|
||||||
updateBounds(Double.toString(d));
|
updateBounds(Double.toString(d));
|
||||||
}
|
}
|
||||||
|
public String append(double d) {
|
||||||
|
this.sb.append(d);
|
||||||
|
updateBounds(Double.toString(d));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public String append(char c) {
|
public String append(char c) {
|
||||||
this.sb=new StringBuilder(c);
|
this.sb.append(c);
|
||||||
updateBounds(Character.toString(c));
|
updateBounds(Character.toString(c));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -80,12 +80,8 @@ public class EditorRenderer extends LevelRenderer{
|
|||||||
if (messageLog.length()>0) {
|
if (messageLog.length()>0) {
|
||||||
if (System.currentTimeMillis()-last_message_log>MESSAGE_TIME) {
|
if (System.currentTimeMillis()-last_message_log>MESSAGE_TIME) {
|
||||||
last_message_log=System.currentTimeMillis();
|
last_message_log=System.currentTimeMillis();
|
||||||
if (messageLog.length()>1) {
|
int secondMarker = messageLog.indexOf("\n",messageLog.indexOf("\n")+1);
|
||||||
int secondMarker = messageLog.indexOf("\n",messageLog.indexOf("\n")+1);
|
messageLog.replace(messageLog.indexOf("\n"), secondMarker==-1?messageLog.length():secondMarker, "");
|
||||||
messageLog.replace(messageLog.indexOf("\n"), secondMarker==-1?messageLog.length():secondMarker, "");
|
|
||||||
} else {
|
|
||||||
messageLog.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user