Interface Hittable
public interface Hittable
Interface representing objects that can be hit or take damage in the game.
-
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the diameter of the object.javafx.geometry.Rectangle2DReturns the hitbox of the object for collision detection.booleanisAlive()Checks whether the object is still alive.voidonDead()Called when the object dies or is destroyed.voidonHit(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.
-