hello guys, i am using below game loop for a long time now, i want to now if this is a correct approach or if i can improve a little bit more,
i would like to add a delta to update method but i dont know how that will impact
public final void run()
{
long lastTime= System.nanoTime();
double amountOfTicks=60.0;
double ns= 1000000000 / amountOfTicks;
double delta=0;
long timer= System.currentTimeMillis();
// int frames=0;
while(running)
{
if(!pause)
{
long now= System.nanoTime();
delta+=(now - lastTime)/ns;
lastTime = now;
while(delta >= 1)
{
update();
//render();
delta--;
}
if(running)
render();
//codigo para checar los frames
frames++;
if(System.currentTimeMillis() - timer > 1000)
{
timer +=1000;
//System.out.println("FPS: "+frames);
frames=0;
}
}//
}//uail