コード例 #1
0
ファイル: Game.java プロジェクト: Jademalo/DorfElf
  /** Runs the game (the "main loop") */
  private static void run() {
    while (!finished) {
      // Always call Window.update(), all the time
      Display.update();

      if (Display.isCloseRequested()) {
        // Check for O/S close requests
        finished = true;
      } else if (Display.isActive()) {
        // The window is in the foreground, so we should play the game
        logic();
        render();
        Display.sync(FRAMERATE);
      } else {
        // The window is not in the foreground, so we can allow other stuff to run and
        // infrequently update
        try {
          Thread.sleep(100);
        } catch (InterruptedException e) {
        }
        logic();
        if (Display.isVisible() || Display.isDirty()) {
          // Only bother rendering if the window is visible or dirty
          render();
        }
      }
    }
  }
コード例 #2
0
ファイル: Execution.java プロジェクト: XeTK/BlockJumper-Game
  public void runtime() throws IOException {
    Logic logic = new Logic();
    while (!finished) {
      Display.update();

      if (Display.isCloseRequested()) finished = true;
      else if (Display.isActive()) logic.logic(blocks, player);

      if (Display.isVisible() || Display.isDirty()) globaldraw();
    }
  }