Class ItemModel

java.lang.Object
model.itemesAndRewards.ItemModel
Direct Known Subclasses:
BubbleRewardModel, PowerUpModel

public abstract class ItemModel extends Object
Represents an abstract item in the game.

The `ItemModel` class serves as a base class for all items in the game. It provides common properties and methods for handling item behavior.

  • Field Details

    • timer

      protected final PlayingTimer timer
    • x

      protected int x
    • y

      protected int y
    • hitbox

      protected Rectangle2D.Float hitbox
    • itemType

      protected Constants.Items.ItemType itemType
    • deSpawnTimer

      protected int deSpawnTimer
    • deSpawning

      protected boolean deSpawning
    • active

      protected boolean active
    • collected

      protected boolean collected
  • Constructor Details

    • ItemModel

      public ItemModel(int x, int y, Constants.Items.ItemType itemType)
      Constructs a new `ItemModel` with the specified position and item type.
      Parameters:
      x - the x-coordinate of the item
      y - the y-coordinate of the item
      itemType - the type of the item
  • Method Details

    • addPoints

      public abstract void addPoints()
      Adds points to the player's score based on the item type.
    • applyEffect

      public abstract void applyEffect()
      Applies the effect of the item to the player.
    • update

      protected void update()
      Updates the state of the item.
    • initHitbox

      protected void initHitbox()
      Initializes the hitbox for the item.
    • getHitbox

      public Rectangle2D.Float getHitbox()
      Returns the hitbox of the item.
      Returns:
      the hitbox of the item
    • isActive

      public boolean isActive()
      Checks if the item is active.
      Returns:
      true if the item is active, false otherwise
    • isDeSpawning

      public boolean isDeSpawning()
      Checks if the item is despawning.
      Returns:
      true if the item is despawning, false otherwise
    • deactivateItem

      public void deactivateItem()
      Deactivates the item.
    • setCollected

      public void setCollected(boolean collected)
      Sets the collected state of the item.
      Parameters:
      collected - true if the item is collected, false otherwise
    • isCollected

      public boolean isCollected()
      Checks if the item is collected.
      Returns:
      true if the item is collected, false otherwise
    • getItemType

      public Constants.Items.ItemType getItemType()
      Returns the type of the item.
      Returns:
      the type of the item