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