Class ProjectileView

java.lang.Object
view.projectiles.ProjectileView
Direct Known Subclasses:
LightingProjectileView, MaitaFireProjectileView, PlayerBubbleProjectileView

public abstract class ProjectileView extends Object
Abstract class representing the view of the ProjectileModel class. Handles the animation and rendering of projectiles.
  • Field Details

    • projectileModel

      protected ProjectileModel projectileModel
    • projectileManagerView

      protected final ProjectileManagerView projectileManagerView
    • animationIndex

      protected int animationIndex
    • animationTick

      protected float animationTick
  • Constructor Details

    • ProjectileView

      protected ProjectileView(ProjectileModel projectileModel)
      Constructs a ProjectileView with the specified ProjectileModel. Initializes the projectile model and plays the sound effect.
      Parameters:
      projectileModel - the model of the projectile
  • Method Details

    • draw

      protected abstract void draw(Graphics g)
      Draws the projectile on the screen.
      Parameters:
      g - the Graphics object to draw the projectile
    • update

      protected void update()
      Updates the state of the projectile view, including its animation tick.
    • playSoundEffect

      protected abstract void playSoundEffect()
      Plays the sound effect associated with the projectile.
    • updateAnimationTick

      protected void updateAnimationTick()
      Updates the animation tick and index for the projectile.
    • isActive

      protected boolean isActive()
      Checks if the projectile is active.

      Active projectiles views are active only if the projectile model is active.

      Returns:
      true if the projectile is active, false otherwise
    • getAnimation

      protected static int getAnimation(Constants.Projectiles.ProjectileState projectileState)
      Returns the animation index for the specified projectile state.
      Parameters:
      projectileState - the state of the projectile
      Returns:
      the animation index
    • getSpriteAmount

      protected static int getSpriteAmount(Constants.Projectiles.ProjectileState projectileState, Constants.Projectiles.ProjectileType projectileType)
      Returns the number of sprites for the specified projectile state and type.
      Parameters:
      projectileState - the state of the projectile
      projectileType - the type of the projectile
      Returns:
      the number of sprites