示例#1
0
  private void updateShooting() {
    if (Mouse.getButton() == 1 && fireRate <= 0) {
      double dx = Mouse.getX() - GameMain.getWindowWidth() / 2;
      double dy = Mouse.getY() - GameMain.getWindowHeight() / 2;
      double dir = Math.atan2(dy, dx);

      shoot(x, y, dir);
      fireRate = WizardProjectile.FIRE_RATE;
    }

    healthBar.setProgress(health / 100.0);
  }
示例#2
0
  public Player(int x, int y, Keyboard input) {
    this.x = x;
    this.y = y;
    this.input = input;
    sprite = Sprite.player_forward;
    fireRate = WizardProjectile.FIRE_RATE;
    ui = GameMain.getUIManager();
    UIPanel panel =
        new UIPanel(
            new Vector2i((230) * GameMain.scale, 0 * GameMain.scale),
            new Vector2i(70 * GameMain.scale, (300 / 16 * 9 + 10) * GameMain.scale));
    ui.addPanel(panel);

    healthBar =
        new HealthBar(
            new Vector2i(232 * GameMain.scale, 60 * GameMain.scale),
            new Vector2i(60 * GameMain.scale, 10 * GameMain.scale));
    healthBar.setColor(0xff6a6a6a);
    healthBar.setForegroundColor(0xffcc2a2a);
    panel.addComponent(healthBar);
  }