Class Enemy
java.lang.Object
core.GameObject
core.Character
entities.enemies.Enemy
- All Implemented Interfaces:
Hittable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleVisual flash effect when the enemy takes damage (0 = none, 1 = full).protected RoomReference to the room where the enemy exists.Fields inherited from class core.GameObject
x, y -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the current damage flash value.getRoom()Returns the room this enemy belongs to.booleanisAlive()Checks if the enemy is alive.booleanisDead()Checks whether the enemy is dead.voidonDead()Called when the enemy dies.voidonHit(int damage) Called when the enemy takes damage.abstract voidrender(javafx.scene.canvas.GraphicsContext gc) Renders the enemy on the screen.voidsetDamageFlash(double damageFlash) Sets the damage flash value.voidSets the room this enemy belongs to.abstract voidupdate(double dt) Updates the enemy state each frame.Methods inherited from class core.Character
getDiameter, getHitbox, getHp, getMaxHp, getPower, setAlive, setDiameter, setHp, setMaxHp, setPowerMethods inherited from class core.GameObject
getX, getY, setX, setYMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface core.Hittable
getDiameter, getHitbox
-
Field Details
-
room
Reference to the room where the enemy exists. -
damageFlash
private double damageFlashVisual flash effect when the enemy takes damage (0 = none, 1 = full).
-
-
Constructor Details
-
Enemy
Constructs an Enemy.- Parameters:
x- Initial X position.y- Initial Y position.hp- Health points.power- Attack power.room- Room where the enemy is located.diameter- Diameter for hitbox and rendering.
-
-
Method Details
-
isDead
-
onHit
-
getDamageFlash
public double getDamageFlash()Returns the current damage flash value.- Returns:
- Damage flash (0–1).
-
setDamageFlash
public void setDamageFlash(double damageFlash) Sets the damage flash value.- Parameters:
damageFlash- Value to set (0–1).
-
isAlive
-
onDead
-
getRoom
-
setRoom
-
update
public abstract void update(double dt) Updates the enemy state each frame.- Specified by:
updatein classGameObject- Parameters:
dt- Delta time since last update (seconds).
-
render
public abstract void render(javafx.scene.canvas.GraphicsContext gc) Renders the enemy on the screen.- Specified by:
renderin classGameObject- Parameters:
gc- GraphicsContext used for rendering.
-