Exemplo n.º 1
0
  public void processFire(Bullet bullet) throws InterruptedException {

    this.bullet = bullet;

    Direction tankDirection = tank.getDirection();

    while (bullet.getY() > minusLimit
        && bullet.getY() < plusLimit
        && bullet.getX() > minusLimit
        && bullet.getX() < plusLimit) {
      if (tankDirection == Direction.UP) {
        bullet.updateY(-1);
      } else if (tankDirection == Direction.DOWN) {
        bullet.updateY(1);
      } else if (tankDirection == Direction.LEFT) {
        bullet.updateX(-1);
      } else if (tankDirection == Direction.RIGHT) {
        bullet.updateX(1);
      }

      if (processInterception()) {
        bullet.destroy();
      }

      repaint();
      Thread.sleep(bullet.getSpeed());
    }
  }
Exemplo n.º 2
0
 private void repaintFire() throws InterruptedException {
   repaint();
   Thread.sleep(bullet.getSpeed());
 }