Class ItemView

java.lang.Object
view.itemsAndRewards.ItemView
Direct Known Subclasses:
BubbleRewardView, PowerUpView

public abstract class ItemView extends Object
The abstract ItemView class represents the view for a ItemModel. It handles drawing the item, playing audio effects, and updating the item's state.
  • Field Details

    • itemModel

      protected ItemModel itemModel
    • itemManagerView

      protected ItemManagerView itemManagerView
    • animationTick

      protected int animationTick
    • animationIndex

      protected int animationIndex
    • soundPlayed

      protected boolean soundPlayed
  • Constructor Details

    • ItemView

      public ItemView(ItemModel itemModel)
      Constructs an ItemView with the specified ItemModel.
      Parameters:
      itemModel - the model of the item
  • Method Details

    • draw

      public abstract void draw(Graphics g)
      Draws the item on the screen.
      Parameters:
      g - the Graphics object to draw with
    • audioEffects

      public abstract void audioEffects()
      Plays the audio effects for the item.
    • update

      public void update()
      Updates the item's state. If the item is de-spawning, updates the animation tick.
    • updateAnimationTick

      protected void updateAnimationTick()
      Updates the animation tick for the de-spawning animation. Increments the animation tick and index.
    • isActive

      protected Boolean isActive()
      Checks if the item is active.
      Returns:
      true if the item is active, false otherwise
    • getItemModel

      protected ItemModel getItemModel()
      Returns the ItemModel associated with this view.
      Returns:
      the ItemModel