Class PlayerBubbleProjectileModel


public class PlayerBubbleProjectileModel extends ProjectileModel
Represents the logic of a player bubble projectile in the game.
  • Constructor Details

    • PlayerBubbleProjectileModel

      public PlayerBubbleProjectileModel(float x, float y, Constants.Direction direction)
      Constructs a PlayerBubbleProjectileModel with the specified position and direction.
      Parameters:
      x - the x-coordinate of the projectile
      y - the y-coordinate of the projectile
      direction - the direction of the projectile
  • Method Details

    • updatePos

      protected void updatePos()
      Updates the position of the projectile.

      Moves the projectile left or right based on its direction.

      Specified by:
      updatePos in class ProjectileModel
    • updateTimer

      protected void updateTimer()
      Updates the active timer and transforms the projectile into a floating bubble if the timer reaches zero.
      Overrides:
      updateTimer in class ProjectileModel
    • checkEnemyHit

      protected void checkEnemyHit(EnemyModel enemyModel, PlayerModel playerModel)
      Checks if the projectile hits an enemy.

      If the projectile hits an active and enemy, it captures the enemy in a bubble and deactivates the projectile.

      Specified by:
      checkEnemyHit in class ProjectileModel
      Parameters:
      enemyModel - the enemy model to check against
      playerModel - the player model to add score to if the enemy is killed (not used in this case)
    • checkPlayerHit

      protected void checkPlayerHit(PlayerModel playerModel)
      Checks if the projectile hits the player.

      This method is not used as player bubbles cannot hit players.

      Specified by:
      checkPlayerHit in class ProjectileModel
      Parameters:
      playerModel - the player model to check against