org.lwjglb.engine.Window类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(161)

本文整理了Java中org.lwjglb.engine.Window类的一些代码示例,展示了Window类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window类的具体详情如下:
包路径:org.lwjglb.engine.Window
类名称:Window

Window介绍

暂无

代码示例

代码示例来源:origin: lwjglgamedev/lwjglbook

public GameEngine(String windowTitle, int width, int height, boolean vSync, IGameLogic gameLogic) throws Exception {
  gameLoopThread = new Thread(this, "GAME_LOOP_THREAD");
  window = new Window(windowTitle, width, height, vSync);
  this.gameLogic = gameLogic;
  timer = new Timer();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

@Override
  public void render(Window window) {
    if ( window.isResized() ) {
      glViewport(0, 0, window.getWidth(), window.getHeight());
      window.setResized(false);
    }

    window.setClearColor(color, color, color, 0.0f);
    renderer.clear();
  }
}

代码示例来源:origin: lwjglgamedev/lwjglbook

@Override
public void input(Window window) {
  if (window.isKeyPressed(GLFW_KEY_UP)) {
    direction = 1;
  } else if (window.isKeyPressed(GLFW_KEY_DOWN)) {
    direction = -1;
  } else {
    direction = 0;
  }
}

代码示例来源:origin: lwjglgamedev/lwjglbook

public void updateSize(Window window) {
    this.statusTextItem.setPosition(10f, window.getHeight() - 50f, 0);
    this.compassItem.setPosition(window.getWidth() - 40f, 50f, 0);
  }
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected void render() {
  if ( window.getWindowOptions().showFps && timer.getLastLoopTime() - lastFps > 1 ) {
    lastFps = timer.getLastLoopTime();
    window.setWindowTitle(windowTitle + " - " + fps + " FPS");
    fps = 0;
  }
  fps++;
  gameLogic.render(window);
  window.update();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected void gameLoop() {
  float elapsedTime;
  float accumulator = 0f;
  float interval = 1f / TARGET_UPS;
  boolean running = true;
  while (running && !window.windowShouldClose()) {
    elapsedTime = timer.getElapsedTime();
    accumulator += elapsedTime;
    input();
    while (accumulator >= interval) {
      update(interval);
      accumulator -= interval;
    }
    render();
    if ( !window.isvSync() ) {
      sync();
    }
  }
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected void init() throws Exception {
  window.init();
  timer.init();
  gameLogic.init();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected void render() {
    gameLogic.render(window);
    window.update();
  }
}

代码示例来源:origin: lwjglgamedev/lwjglbook

public void init(Window window) {
  glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
    currentPos.x = xpos;
    currentPos.y = ypos;
  });
  glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
    inWindow = entered;
  });
  glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
    leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
    rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
  });
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected void gameLoop() {
  float elapsedTime;
  float accumulator = 0f;
  float interval = 1f / TARGET_UPS;
  boolean running = true;
  while (running && !window.windowShouldClose()) {
    elapsedTime = timer.getElapsedTime();
    accumulator += elapsedTime;
    input();
    while (accumulator >= interval) {
      update(interval);
      accumulator -= interval;
    }
    render();
    if ( !window.isvSync() ) {
      sync();
    }
  }
}

代码示例来源:origin: lwjglgamedev/lwjglbook

public void updateSize(Window window) {
    this.statusTextItem.setPosition(10f, window.getHeight() - 50f, 0);
    this.compassItem.setPosition(window.getWidth() - 40f, 50f, 0);
  }
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected void init() throws Exception {
  window.init();
  timer.init();
  gameLogic.init();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected void render() {
    gameLogic.render(window);
    window.update();
  }
}

代码示例来源:origin: lwjglgamedev/lwjglbook

public void init(Window window) {
  glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
    currentPos.x = xpos;
    currentPos.y = ypos;
  });
  glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
    inWindow = entered;
  });
  glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
    leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
    rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
  });
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected void render() {
  if ( window.getWindowOptions().showFps && timer.getLastLoopTime() - lastFps > 1 ) {
    lastFps = timer.getLastLoopTime();
    window.setWindowTitle(windowTitle + " - " + fps + " FPS");
    fps = 0;
  }
  fps++;
  gameLogic.render(window);
  window.update();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

public void render(Window window, Camera camera, GameItem[] gameItems,
    SceneLight sceneLight, IHud hud) {
  clear();
  if ( window.isResized() ) {
    glViewport(0, 0, window.getWidth(), window.getHeight());
    window.setResized(false);
  }
  renderScene(window, camera, gameItems, sceneLight);
  renderHud(window, hud);
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected void gameLoop() {
  float elapsedTime;
  float accumulator = 0f;
  float interval = 1f / TARGET_UPS;
  boolean running = true;
  while (running && !window.windowShouldClose()) {
    elapsedTime = timer.getElapsedTime();
    accumulator += elapsedTime;
    input();
    while (accumulator >= interval) {
      update(interval);
      accumulator -= interval;
    }
    render();
    if (!window.isvSync()) {
      sync();
    }
  }
}

代码示例来源:origin: lwjglgamedev/lwjglbook

public void updateSize(Window window) {
    this.statusTextItem.setPosition(10f, window.getHeight() - 50f, 0);
    this.compassItem.setPosition(window.getWidth() - 40f, 50f, 0);
  }
}

代码示例来源:origin: lwjglgamedev/lwjglbook

public GameEngine(String windowTitle, int width, int height, boolean vSync, IGameLogic gameLogic) throws Exception {
  gameLoopThread = new Thread(this, "GAME_LOOP_THREAD");
  window = new Window(windowTitle, width, height, vSync);
  this.gameLogic = gameLogic;
  timer = new Timer();
}

代码示例来源:origin: lwjglgamedev/lwjglbook

protected void init() throws Exception {
  window.init();
  timer.init();
  mouseInput.init(window);
  gameLogic.init(window);
}

相关文章