i had another gameloop before but tried this one still does the same thing
its stuck at 30Fps for some reason
my Jframe is on FullScreen might be good to know!
any ideas why?
am not rendering anything or doing anyting it just gets stuck on 30 for some reason
Console
(FPS: 0)
(FPS: 1)
(FPS: 2)
(FPS: 3)
(FPS: 4)
(FPS: 5)
(FPS: 6)
(FPS: 7)
(FPS: 8)
(FPS: 9)
(FPS: 10)
(FPS: 11)
(FPS: 12)
(FPS: 13)
(FPS: 14)
(FPS: 15)
(FPS: 16)
(FPS: 17)
(FPS: 18)
(FPS: 19)
(FPS: 20)
(FPS: 21)
(FPS: 22)
(FPS: 23)
(FPS: 24)
(FPS: 25)
(FPS: 26)
(FPS: 27)
(FPS: 28)
(FPS: 29)
(FPS: 30)
(FPS: 0)
(FPS: 1)
(FPS: 2)
(FPS: 3)
(FPS: 4)
(FPS: 5)
(FPS: 6)
(FPS: 7)
(FPS: 8)
(FPS: 9)
(FPS: 10)
(FPS: 11)
(FPS: 12)
(FPS: 13)
(FPS: 14)
(FPS: 15)
(FPS: 16)
(FPS: 17)
(FPS: 18)
(FPS: 19)
(FPS: 20)
(FPS: 21)
(FPS: 22)
(FPS: 23)
(FPS: 24)
(FPS: 25)
(FPS: 26)
(FPS: 27)
(FPS: 28)
(FPS: 29)
(FPS: 30)
(FPS: 0)
(FPS: 1)
(FPS: 2)
(FPS: 3)
(FPS: 4)
(FPS: 5)
(FPS: 6)
(FPS: 7)
(FPS: 8)
(FPS: 9)
(FPS: 10)
(FPS: 11)
(FPS: 12)
(FPS: 13)
(FPS: 14)
(FPS: 15)
(FPS: 16)
(FPS: 17)
(FPS: 18)
(FPS: 19)
(FPS: 20)
(FPS: 21)
(FPS: 22)
(FPS: 23)
(FPS: 24)
(FPS: 25)
(FPS: 26)
(FPS: 27)
(FPS: 28)
(FPS: 29)
(FPS: 30)
@Override
public void run() {
init();
long lastLoopTime = System.nanoTime();
final int TARGET_FPS = 60;
final long OPTIMAL_TIME = 1000000000 / TARGET_FPS;
while(running){
long now = System.nanoTime();
long updateLength = now - lastLoopTime;
lastLoopTime = now;
double deltaTime = updateLength / ((double)OPTIMAL_TIME);
lastFpsTime += updateLength;
frames++;
if (lastFpsTime >= 1000000000)
{
System.out.println("(FPS: "+frames+")");
lastFpsTime = 0;
frames = 0;
}
System.out.println("(FPS: "+frames+")");
if(!isPaused()){
tick(deltaTime);
clear();
render();
}else{
Pausedtick(deltaTime);
Pausedrender();
}
try{
Thread.sleep((lastLoopTime-System.nanoTime() * OPTIMAL_TIME) / 1000000);
}catch(Exception e){
}
}
}
The Clear Method
public void clear() {
Graphics g2 = getGraphics();
if(img != null){
g2.drawImage(img, 0, 0, null);
}
g2.dispose();
}
The Render Method
public void render(){
graphics2d.clearRect(0, 0, width, height);
graphics2d.drawString(getFps()+"", 20, 20);
}