Class Chaser
java.lang.Object
core.GameObject
core.Character
entities.enemies.Enemy
entities.enemies.Chaser
- All Implemented Interfaces:
Hittable
Represents a Chaser enemy in the game.
The Chaser moves toward the player along one axis at a time,
and charges at the player when aligned horizontally or vertically.
Upon death, it spawns a coin and four bullets in four directions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final doubleNormal movement speed in pixels per second.private static final doubleCharging speed when aligned with the player.private static final javafx.scene.image.ImageStatic image used to render the Chaser sprite.private PlayerReference to the player object.private doubleHorizontal velocity component.private doubleVertical velocity component.Fields inherited from class core.GameObject
x, y -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the player object that the Chaser is targeting.voidonDead()Called when the Chaser dies.voidrender(javafx.scene.canvas.GraphicsContext gc) Renders the Chaser, including its sprite and damage flash.voidSets the player object that the Chaser targets.voidupdate(double dt) Updates the Chaser's position and damage flash each frame.Methods inherited from class entities.enemies.Enemy
getDamageFlash, getRoom, isAlive, isDead, onHit, setDamageFlash, setRoomMethods 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
-
baseSpeed
private static final double baseSpeedNormal movement speed in pixels per second.- See Also:
-
chargeSpeed
private static final double chargeSpeedCharging speed when aligned with the player.- See Also:
-
vx
private double vxHorizontal velocity component. -
vy
private double vyVertical velocity component. -
player
Reference to the player object. -
CHASER_SPRITE
private static final javafx.scene.image.Image CHASER_SPRITEStatic image used to render the Chaser sprite.
-
-
Constructor Details
-
Chaser
Constructs a new Chaser enemy.- Parameters:
x- Initial X position.y- Initial Y position.room- Room the enemy is in.player- Reference to the player.hp- Health points of the Chaser.power- Attack power of the Chaser.diameter- Diameter of the Chaser for hitbox and rendering.
-
-
Method Details
-
onDead
-
update
-
render
-
getPlayer
Returns the player object that the Chaser is targeting.- Returns:
- Player object.
-
setPlayer
Sets the player object that the Chaser targets.- Parameters:
player- Player object.
-