Interface Hittable

All Known Implementing Classes:
Boss, Character, Chaser, Enemy, Jumper, Player

public interface Hittable
Interface representing objects that can be hit or take damage in the game.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the diameter of the object.
    javafx.geometry.Rectangle2D
    Returns the hitbox of the object for collision detection.
    boolean
    Checks whether the object is still alive.
    void
    Called when the object dies or is destroyed.
    void
    onHit(int damage)
    Called when the object is hit and takes damage.
  • Method Details

    • onHit

      void onHit(int damage)
      Called when the object is hit and takes damage.
      Parameters:
      damage - The amount of damage inflicted.
    • onDead

      void onDead()
      Called when the object dies or is destroyed. Can be used to trigger effects, drops, or removal from the game world.
    • isAlive

      boolean isAlive()
      Checks whether the object is still alive.
      Returns:
      true if the object is alive, false otherwise.
    • getDiameter

      double getDiameter()
      Returns the diameter of the object. Used for calculating hitboxes, rendering, and collision areas.
      Returns:
      Diameter of the object.
    • getHitbox

      javafx.geometry.Rectangle2D getHitbox()
      Returns the hitbox of the object for collision detection.
      Returns:
      Rectangle2D representing the object's hitbox.