Class TreasureBox
java.lang.Object
entities.items.Item
entities.items.TreasureBox
- All Implemented Interfaces:
Collectible
A collectible treasure box item.
When collected, grants the player a fixed amount of coins.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intAmount of coins granted when collected.private static final doubleHeight of the treasure box sprite.private static final javafx.scene.image.ImageSprite image for the treasure box.private static final doubleWidth of the treasure box sprite. -
Constructor Summary
ConstructorsConstructorDescriptionTreasureBox(double x, double y) Constructs a new TreasureBox at the specified position. -
Method Summary
-
Field Details
-
WIDTH
private static final double WIDTHWidth of the treasure box sprite.- See Also:
-
HEIGHT
private static final double HEIGHTHeight of the treasure box sprite.- See Also:
-
COINAMOUNT
private static final int COINAMOUNTAmount of coins granted when collected.- See Also:
-
TREASURE_SPRITE
private static final javafx.scene.image.Image TREASURE_SPRITESprite 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 centery- Y coordinate of the item center
-
-
Method Details
-
collect
Collects the treasure box and grants coins to the player.- Specified by:
collectin interfaceCollectible- Specified by:
collectin classItem- 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:
renderin interfaceCollectible- Specified by:
renderin classItem- Parameters:
gc- GraphicsContext used for rendering
-