Class Boss
java.lang.Object
core.GameObject
core.Character
entities.enemies.Enemy
entities.enemies.Boss
- All Implemented Interfaces:
Hittable,SpecialAbilityCapable
Represents a boss enemy in the game.
The Boss has multiple attack abilities, can move and charge toward the player,
and uses a special ability periodically. Drops coins and increases difficulty upon death.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether the boss is currently performing an action.private static final javafx.scene.image.ImageStatic image used for rendering the boss sprite.private static doubleCharging speed of the boss (pixels/sec).private longTimestamp of the last special ability usage.private intMaximum health points of the boss.private PlayerReference to the player object for targeting and attacks.private static doubleCooldown for the special ability in milliseconds.private doubleTarget X position for movement/charge.private doubleTarget Y position for movement/charge.private static doubleNormal walking speed of the boss (pixels/sec).Fields inherited from class core.GameObject
x, y -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidblurp()Boss ability: shoots shotgun-like bullets toward the player.voidcharge()Boss ability: charges toward a target near the player.private voidInternal AI loop that continuously decides the boss's actions including walking, shooting, special attacks, and charging.voidonDead()Called when the boss dies.voidrender(javafx.scene.canvas.GraphicsContext gc) Renders the boss, including sprite, damage flash, and HP bar.voidshoot()Boss ability: shoots bullets in a circular pattern.voidSpawns bullets in a circle around the boss.voidShoots a single spread of bullets toward the player.private voidsmoothMoveSpeed(double seconds, double speed) Smoothly moves the boss toward a target position at a given speed.voidupdate(double dt) Updates the boss state each frame (damage flash, etc.).voidExecutes the boss's special ability: spinning circular bullet attack.voidwalk()Makes the boss walk toward the player for a fixed duration.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
-
player
Reference to the player object for targeting and attacks. -
maxHp
private int maxHpMaximum health points of the boss. -
acting
private volatile boolean actingWhether the boss is currently performing an action. -
targetX
private double targetXTarget X position for movement/charge. -
targetY
private double targetYTarget Y position for movement/charge. -
walkSpeed
private static double walkSpeedNormal walking speed of the boss (pixels/sec). -
chargeSpeed
private static double chargeSpeedCharging speed of the boss (pixels/sec). -
specialAbilityCooldown
private static double specialAbilityCooldownCooldown for the special ability in milliseconds. -
lastSpecial
private long lastSpecialTimestamp of the last special ability usage. -
BOSS_SPRITE
private static final javafx.scene.image.Image BOSS_SPRITEStatic image used for rendering the boss sprite.
-
-
Constructor Details
-
Boss
Constructs a new Boss.- Parameters:
x- Initial X position.y- Initial Y position.room- Room the boss is located in.hp- Health points of the boss.power- Attack power.player- Reference to the player object.diameter- Diameter of the boss hitbox.
-
-
Method Details
-
loopBehavior
private void loopBehavior()Internal AI loop that continuously decides the boss's actions including walking, shooting, special attacks, and charging. -
useSpecialAbility
public void useSpecialAbility()Executes the boss's special ability: spinning circular bullet attack.- Specified by:
useSpecialAbilityin interfaceSpecialAbilityCapable
-
walk
Makes the boss walk toward the player for a fixed duration.- Throws:
InterruptedException- If thread is interrupted.
-
shoot
Boss ability: shoots bullets in a circular pattern.- Throws:
InterruptedException- If thread is interrupted.
-
shootCircle
public void shootCircle()Spawns bullets in a circle around the boss. -
blurp
Boss ability: shoots shotgun-like bullets toward the player.- Throws:
InterruptedException- If thread is interrupted.
-
shotgunOnce
public void shotgunOnce()Shoots a single spread of bullets toward the player. -
charge
Boss ability: charges toward a target near the player.- Throws:
InterruptedException- If thread is interrupted.
-
smoothMoveSpeed
Smoothly moves the boss toward a target position at a given speed.- Parameters:
seconds- Duration of movement.speed- Speed in pixels per second.- Throws:
InterruptedException- If thread is interrupted.
-
onDead
-
update
-
render
-