コード例 #1
0
  public void update(float delta) {
    if (Keyboard.isClicked(Keyboard.KEY_ESCAPE)) end();

    float speed = 2 * delta;

    if (Keyboard.isPressed(Keyboard.KEY_W)) cam.moveForward(speed);

    if (Keyboard.isPressed(Keyboard.KEY_S)) cam.moveBackward(speed);

    if (Keyboard.isPressed(Keyboard.KEY_A)) cam.moveLeft(speed);

    if (Keyboard.isPressed(Keyboard.KEY_D)) cam.moveRight(speed);

    if (Keyboard.isPressed(Keyboard.KEY_Q)) cam.moveUp(speed);

    if (Keyboard.isPressed(Keyboard.KEY_E)) cam.moveDown(speed);

    if (Keyboard.isPressed(Keyboard.KEY_UP)) cam.rotateX(1);

    if (Keyboard.isPressed(Keyboard.KEY_DOWN)) cam.rotateX(-1);

    if (Keyboard.isPressed(Keyboard.KEY_LEFT)) cam.rotateY(1);

    if (Keyboard.isPressed(Keyboard.KEY_RIGHT)) cam.rotateY(-1);

    // Mouse look!
    if (Keyboard.isPressed(Keyboard.KEY_SPACE)) {
      if (!Display.isCursorGrabbed()) Display.grabCursor();

      cam.rotateX(Mouse.getDY() * speed);
      cam.rotateY(Mouse.getDX() * speed);
    } else Display.showCursor();

    entity.rotate(0, 0, 90 * delta);
    scene.update(delta);

    // Calculate the new memory used again
    long newUsedMemory = (getUsedMemory() / 1048576);
    usedMemory = Math.max(usedMemory, newUsedMemory);

    Display.setTitle(
        "Total Memory: "
            + (getTotalMemory() / 1048576)
            + "MB / Free Memory: "
            + (getFreeMemory() / 1048576)
            + "MB / Used Memory: "
            + newUsedMemory
            + "MB");
  }
コード例 #2
0
 public void preInit() {
   Display.setTitle("BillBoard Model Test");
   Display.setSize(1280, 720);
 }