Class Boss

All Implemented Interfaces:
Hittable, SpecialAbilityCapable

public class Boss extends Enemy implements 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

    Fields
    Modifier and Type
    Field
    Description
    private boolean
    Whether the boss is currently performing an action.
    private static final javafx.scene.image.Image
    Static image used for rendering the boss sprite.
    private static double
    Charging speed of the boss (pixels/sec).
    private long
    Timestamp of the last special ability usage.
    private int
    Maximum health points of the boss.
    private Player
    Reference to the player object for targeting and attacks.
    private static double
    Cooldown for the special ability in milliseconds.
    private double
    Target X position for movement/charge.
    private double
    Target Y position for movement/charge.
    private static double
    Normal walking speed of the boss (pixels/sec).

    Fields inherited from class entities.enemies.Enemy

    room

    Fields inherited from class core.Character

    diameter, isAlive

    Fields inherited from class core.GameObject

    x, y
  • Constructor Summary

    Constructors
    Constructor
    Description
    Boss(double x, double y, Room room, int hp, int power, Player player, double diameter)
    Constructs a new Boss.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Boss ability: shoots shotgun-like bullets toward the player.
    void
    Boss ability: charges toward a target near the player.
    private void
    Internal AI loop that continuously decides the boss's actions including walking, shooting, special attacks, and charging.
    void
    Called when the boss dies.
    void
    render(javafx.scene.canvas.GraphicsContext gc)
    Renders the boss, including sprite, damage flash, and HP bar.
    void
    Boss ability: shoots bullets in a circular pattern.
    void
    Spawns bullets in a circle around the boss.
    void
    Shoots a single spread of bullets toward the player.
    private void
    smoothMoveSpeed(double seconds, double speed)
    Smoothly moves the boss toward a target position at a given speed.
    void
    update(double dt)
    Updates the boss state each frame (damage flash, etc.).
    void
    Executes the boss's special ability: spinning circular bullet attack.
    void
    Makes the boss walk toward the player for a fixed duration.

    Methods inherited from class entities.enemies.Enemy

    getDamageFlash, getRoom, isAlive, isDead, onHit, setDamageFlash, setRoom

    Methods inherited from class core.GameObject

    getX, getY, setX, setY

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface core.Hittable

    getDiameter, getHitbox
  • Field Details

    • player

      private Player player
      Reference to the player object for targeting and attacks.
    • maxHp

      private int maxHp
      Maximum health points of the boss.
    • acting

      private volatile boolean acting
      Whether the boss is currently performing an action.
    • targetX

      private double targetX
      Target X position for movement/charge.
    • targetY

      private double targetY
      Target Y position for movement/charge.
    • walkSpeed

      private static double walkSpeed
      Normal walking speed of the boss (pixels/sec).
    • chargeSpeed

      private static double chargeSpeed
      Charging speed of the boss (pixels/sec).
    • specialAbilityCooldown

      private static double specialAbilityCooldown
      Cooldown for the special ability in milliseconds.
    • lastSpecial

      private long lastSpecial
      Timestamp of the last special ability usage.
    • BOSS_SPRITE

      private static final javafx.scene.image.Image BOSS_SPRITE
      Static image used for rendering the boss sprite.
  • Constructor Details

    • Boss

      public Boss(double x, double y, Room room, int hp, int power, Player player, double diameter)
      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:
      useSpecialAbility in interface SpecialAbilityCapable
    • walk

      public void walk() throws InterruptedException
      Makes the boss walk toward the player for a fixed duration.
      Throws:
      InterruptedException - If thread is interrupted.
    • shoot

      public void shoot() throws InterruptedException
      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

      public void blurp() throws InterruptedException
      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

      public void charge() throws InterruptedException
      Boss ability: charges toward a target near the player.
      Throws:
      InterruptedException - If thread is interrupted.
    • smoothMoveSpeed

      private void smoothMoveSpeed(double seconds, double speed) throws InterruptedException
      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

      public void onDead()
      Called when the boss dies. Spawns coins and increases game difficulty.
      Specified by:
      onDead in interface Hittable
      Overrides:
      onDead in class Enemy
    • update

      public void update(double dt)
      Updates the boss state each frame (damage flash, etc.).
      Specified by:
      update in class Enemy
      Parameters:
      dt - Delta time since last frame.
    • render

      public void render(javafx.scene.canvas.GraphicsContext gc)
      Renders the boss, including sprite, damage flash, and HP bar.
      Specified by:
      render in class Enemy
      Parameters:
      gc - GraphicsContext for rendering.