@Override
 public void collided(Sprite s1, Sprite s2) {
   s1.setActive(false);
   Integer lives = (Integer) ((BetterSprite) s2).getStat("lives").getStat();
   lives -= LIVES_LOST;
   s2.setX(350);
 }
  @Override
  public void render(Graphics2D g) {
    currentPlayField.render(g);

    // handles those few sprites behind the players that we don't want to
    // collide immediately upon creation
    for (Sprite currentSprite : blockQueue) {
      currentSprite.render(g);
    }
  }
예제 #3
0
  @Override
  public void update(long elapsedTime) {
    super.update(elapsedTime);

    // ボタンが左クリックされた時の処理は,他のクラスで定義する。
    if (isMouseLeftButtonPressed()) {
      if (this.bl != null) {
        this.bl.actionPerformed();
      }
    }
  }
예제 #4
0
  @Override
  public void render(Graphics2D g) {
    super.render(g);

    createButtonRect(g, true);
    createText(g);

    // カーソルが重なったら,ボタンを枠で囲む
    if (isMouseCursorOverlaped()) {
      createButtonOutsideRect(g);
    }
  }
  public void deployPlayerBlocks() {
    for (Sprite currentPlayer : currentPlayField.getGroup("humanPlayerGroup").getSprites()) {
      if (currentPlayer != null) {
        blockQueue.add(
            new Sprite(currentPlayer.getImage(), currentPlayer.getX(), currentPlayer.getY()));
      }
    }
    for (Sprite currentPlayer : currentPlayField.getGroup("computerPlayerGroup").getSprites()) {
      if (currentPlayer != null) {
        blockQueue.add(
            new Sprite(currentPlayer.getImage(), currentPlayer.getX(), currentPlayer.getY()));
      }
    }

    while (blockQueue.size() > FPS / 5) {
      playerBlocks.add(blockQueue.remove());
    }
  }
예제 #6
0
    @Override
    public void collided(Sprite s1, Sprite s2) {

      damage = s1.getID();
      health = s2.getID();
      s2.setID(health - damage);
      s1.setID(damage - health);

      s1.setActive(false);

      if (health - damage < 1) {
        s2.setActive(false);
        game.setMoney(game.getMoney() + 10);
      }

      getGroup1().removeInactiveSprites();
      getGroup2().removeInactiveSprites();
    }
예제 #7
0
 public void collided(Sprite player, Sprite enemy) {
   ((Player) player).reduceHealth(damage);
   enemy.setActive(false);
 }