Exemplo n.º 1
0
 private void frameFunction() {
   if (Keyboard.isKeyDown(Keyboard.KEY_F)) {
     try {
       physEngine.update(16);
     } catch (Exception e) {
       physEngine.stepBack();
     }
   } else if (Keyboard.isKeyDown(Keyboard.KEY_R)) {
     physEngine.stepBack();
   }
 }
Exemplo n.º 2
0
  public void update(GameContainer gameContainer, int delta) throws SlickException {
    buttonCooldown += 16;

    if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
      Display.destroy();
      AL.destroy();
      System.exit(0);
    }

    if (buttonCooldown >= 300) {
      if (Keyboard.isKeyDown(Keyboard.KEY_M)) {
        if (MODE == Mode.Normal) {
          MODE = Mode.Frame;
        } else if (MODE == Mode.Frame) {
          MODE = Mode.Normal;
        }
      }
      buttonCooldown = 0;
    }

    spawnCooldown += delta;
    if (Mouse.isButtonDown(0)) {
      spawn(Mouse.getX(), Mouse.getY(), true);
    } else if (Mouse.isButtonDown(1)) {
      spawn(Mouse.getX(), Mouse.getY(), false);
    }

    switch (MODE) {
      case Normal:
        physEngine.update(delta);
        break;
      case Frame:
        frameFunction();
        break;
      case Step:
        if (buttonCooldown < 300) break;
        frameFunction();
        buttonCooldown = 0;
      default:
        break;
    }
  }