Exemplo n.º 1
0
  public void update(long dtime) {
    super.update(dtime);
    if (this.health == 0 && this.dead == false) {
      if (this == Gamestate.getInstance().getPlayer()) {
        this.setController(new NoController());
      }

      SOUNDS.TANK_EXPLODE.play();
      Vector3f bpos = new Vector3f(this.getBase().getPos());
      Gamestate.getInstance().addObject(new ExplosionCluster(bpos, new Vector3f(0, 1.2f, 0), 20));
      this.setController(new NoController());
      this.dead = true;
      this.base.unjoin(this.turret);
      this.parts.remove(this.turret);

    } else {
      lastFired++;
      Vector2f lookdir = turret.getPhys().getDir();
      if (lookdir.y > 25.0f) lookdir.y = 25.0f;
      if (lookdir.y < -25.0f) lookdir.y = -25.0f;

      if (lookdir.x > 55.0f) lookdir.x = 55.0f;
      if (lookdir.x < -55.0f) lookdir.x = -55.0f;

      turret.getPhys().setDir(lookdir);
    }
  }
Exemplo n.º 2
0
  public boolean fire() {

    if (lastFired > fireRate) {
      SOUNDS.FIRE_GUN.play();
      Bullet b = new Bullet();
      b.setTeam(this.getTeam());
      Gamestate.getInstance().addObject(b);
      b.fire(new Vector3f(this.turret.getPos()), new Vector2f(turret.getDir()));

      lastFired = 0;
      return true;
    }
    return false;
  }