delaytimer gefixt

master
Lenz Wiechers 2020-06-08 19:02:06 +02:00
parent 8f45f0cba3
commit e0594daa14
2 changed files with 6 additions and 5 deletions

Binary file not shown.

View File

@ -29,7 +29,7 @@ public class Game {
private JLabel fpsLabel;
private JLabel liveLabels[];
private long delaytimer = 4000;
private int delaytimer = 4;
@SuppressWarnings("unused")
private long fps = 60;
@ -457,24 +457,25 @@ public class Game {
fps = 1000000000 / dt; // Berechnen der fps
if (frames > 100) {
if (fps > 200) {
delaytimer += 100;
delaytimer++;
} else if (fps < 180) {
delaytimer -= 100;
delaytimer--;
}
}
}
delay(delaytimer); // delay ist wichtig, um die geschwindigkeit der objekte und die fps zu
// kontrollieren
System.out.println(delaytimer);
}
// ENDE DES MAIN-LOOPS
}
// Methode zum verzögern (warten) in ms
public void delay(long time) {
public void delay(int time) {
try {
Thread.sleep(0, (int) time);
Thread.sleep(time);
} catch (InterruptedException e) {
e.printStackTrace();
}