Class Coin

All Implemented Interfaces:
Collectible

public class Coin extends Item
A collectible coin item. When collected by the player, adds one coin to the player's inventory and plays a sound effect.
  • Field Details

    • WIDTH

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

      private static final double HEIGHT
      Height of the coin sprite.
      See Also:
    • COIN_SPRITE

      private static javafx.scene.image.Image COIN_SPRITE
      Coin sprite image.
  • Constructor Details

    • Coin

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

    • collect

      public void collect(Player player)
      Collects the coin, giving the player 1 coin and playing a sound effect.
      Specified by:
      collect in interface Collectible
      Specified by:
      collect in class Item
      Parameters:
      player - The player who collects the coin
    • getCoinSprite

      public static javafx.scene.image.Image getCoinSprite()
      Returns the coin sprite image. Loads it if it has not been loaded yet.
      Returns:
      Image representing the coin
    • render

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