Class Chaser

All Implemented Interfaces:
Hittable

public class Chaser extends Enemy
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 Details

    • baseSpeed

      private static final double baseSpeed
      Normal movement speed in pixels per second.
      See Also:
    • chargeSpeed

      private static final double chargeSpeed
      Charging speed when aligned with the player.
      See Also:
    • vx

      private double vx
      Horizontal velocity component.
    • vy

      private double vy
      Vertical velocity component.
    • player

      private Player player
      Reference to the player object.
    • CHASER_SPRITE

      private static final javafx.scene.image.Image CHASER_SPRITE
      Static image used to render the Chaser sprite.
  • Constructor Details

    • Chaser

      public Chaser(double x, double y, Room room, Player player, int hp, int power, double diameter)
      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

      public void onDead()
      Called when the Chaser dies. Spawns bullets in four directions and drops a coin.
      Specified by:
      onDead in interface Hittable
      Overrides:
      onDead in class Enemy
    • update

      public void update(double dt)
      Updates the Chaser's position and damage flash each frame. Moves toward the player along one axis and charges if aligned.
      Specified by:
      update in class Enemy
      Parameters:
      dt - Delta time since last update (seconds).
    • render

      public void render(javafx.scene.canvas.GraphicsContext gc)
      Renders the Chaser, including its sprite and damage flash.
      Specified by:
      render in class Enemy
      Parameters:
      gc - GraphicsContext used for drawing.
    • getPlayer

      public Player getPlayer()
      Returns the player object that the Chaser is targeting.
      Returns:
      Player object.
    • setPlayer

      public void setPlayer(Player player)
      Sets the player object that the Chaser targets.
      Parameters:
      player - Player object.