Example #1
0
 /**
  * Count the number of frames per second. Update the title bar with the count every second.
  *
  * @param millisSkipped The number of milliseconds skipped in the current frame
  */
 public void updateFPS(long millisSkipped) {
   millisecondsSkipped += millisSkipped;
   framesRendered += 1;
   if (Thunderbrand.getTime() - lastFPSTitleUpdate
       > 1000) { // Update the title in one-second increments
     GameInitializer.setWindowTitle(
         "FPS: " + framesRendered + " | Idle time: " + (millisecondsSkipped / 10) + "%");
     framesRendered = 0; // Reset the frames rendered
     millisecondsSkipped = 0; // Reset the milliseconds skipped
     lastFPSTitleUpdate += 1000; // Add one second
   }
 }
Example #2
0
  /**
   * Displays one of the message textures made in MSPaint until the client is closed.
   *
   * @param texture The texture id of the message to display
   * @param width The width of the texture
   * @param height The height of the texture
   * @param optionalTitleChange This message will be shown on the title bar. A {@code null} or empty
   *     string will be ignored.
   * @throws InterruptedException
   */
  public void displayMessageForever(int texture, int width, int height, String optionalTitleChange)
      throws InterruptedException {
    if (optionalTitleChange != null && !optionalTitleChange.trim().isEmpty()) {
      GameInitializer.setWindowTitle(optionalTitleChange);
    }
    while (!Display.isCloseRequested()) {
      GameInitializer.initializeNewFrameForWindow();
      GLDrawer.clear();
      GLDrawer.useTexture(texture);
      GLDrawer.drawQuad(
          32,
          32 + width,
          Crissaegrim.getWindowHeight() - 32 - height,
          Crissaegrim.getWindowHeight() - 32);

      Display.update();
      Thread.sleep(100);
    }
    Display.destroy();
  }