使用游戏循环时,日食的控制台中未显示帧频

时间:2019-07-10 19:27:02

标签: java

我正在YouTube上学习一个教程,他使用的游戏循环会为他显示帧频,但是当我使用相同的游戏循环时,它将不会为我显示帧频

我已经回到视频中,比较了本教程中使用的游戏循环和我必须输入的游戏循环

// the variable running is located here
public synchronized void start() {   
        thread = new Thread(this);
        thread.start();
        running = true;
    }

// game loop
public 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) {
        long now = System.nanoTime();
        delta += (now - lastTime) / ns;
        lastTime = now;
        while (delta >= 1) {
            tick();
            delta--;
        }
     }
     if (running == true) {
         `frames++;
         if ((System.currentTimeMillis() - timer) >= 1000) {
             timer += 1000;
             System.out.println("FPS " + frames);
             frames = 0;
             render();
         }

Here is a link to the tutorial I have been using.

我希望FPS将在控制台中打印出来,但是当我运行程序控制台时,它是空的。

0 个答案:

没有答案