Class TreasureBox

java.lang.Object
entities.items.Item
entities.items.TreasureBox
All Implemented Interfaces:
Collectible

public class TreasureBox extends Item
A collectible treasure box item. When collected, grants the player a fixed amount of coins.
  • Field Details

    • WIDTH

      private static final double WIDTH
      Width of the treasure box sprite.
      See Also:
    • HEIGHT

      private static final double HEIGHT
      Height of the treasure box sprite.
      See Also:
    • COINAMOUNT

      private static final int COINAMOUNT
      Amount of coins granted when collected.
      See Also:
    • TREASURE_SPRITE

      private static final javafx.scene.image.Image TREASURE_SPRITE
      Sprite image for the treasure box.
  • Constructor Details

    • TreasureBox

      public TreasureBox(double x, double y)
      Constructs a new TreasureBox at the specified position.
      Parameters:
      x - X coordinate of the item center
      y - Y coordinate of the item center
  • Method Details

    • collect

      public void collect(Player player)
      Collects the treasure box and grants coins to the player.
      Specified by:
      collect in interface Collectible
      Specified by:
      collect in class Item
      Parameters:
      player - The player who collects the item
    • render

      public void render(javafx.scene.canvas.GraphicsContext gc)
      Renders the treasure box at its current position.
      Specified by:
      render in interface Collectible
      Specified by:
      render in class Item
      Parameters:
      gc - GraphicsContext used for rendering