how can i make an FPS Limiter i never used it and i idk how to make it ? please help
EDIT:
public void run() {
long lastTime = System.nanoTime();
final double amountOfTicks = 60.0;
double ns = 1000000000 / amountOfTicks;
double delta = 0;
int ticks = 0;
frames = 0;
long timer = System.currentTimeMillis();
while (run) {
long now = System.nanoTime();
delta += (now - lastTime) / ns;
lastTime = now;
if (delta >= 1) {
tick();
ticks++;
delta--;
}
render();
frames++;
if (System.currentTimeMillis() - timer > 1000) {
timer += 1000;
//System.out.println("FPS : " + frames + " Ticks : " + ticks);
frames = 0;
ticks = 0;
}
}
}
i was looking for this.