Class: Endboss

Endboss()

Endboss Represents the final boss enemy in the game. Inherits movement and physics from MovableObject. Uses frame-based animations synchronized with display refresh rate.

Constructor

new Endboss()

Initializes the Endboss by: - Loading all animation sequences into the image cache. - Setting the default displayed image to the first alert frame. - Applying gravity. - Setting the starting horizontal position to x = 3800.
Source:

Members

IMAGES_ALERT :Array.<string>

Image paths for the alert animation sequence.
Type:
  • Array.<string>
Source:

IMAGES_ATTACK :Array.<string>

Image paths for the attack animation sequence. Includes repeated frames for visual emphasis.
Type:
  • Array.<string>
Source:

IMAGES_DEAD :Array.<string>

Image paths for the death animation sequence. Includes frames shared with the hurt animation and dedicated death frames.
Type:
  • Array.<string>
Source:

IMAGES_FLYING :Array.<string>

Image paths for the flying animation sequence during recovery.
Type:
  • Array.<string>
Source:

IMAGES_HURT :Array.<string>

Image paths for the hurt animation sequence.
Type:
  • Array.<string>
Source:

IMAGES_INTRO2 :Array.<string>

Image paths for the alert animation intro sequence.
Type:
  • Array.<string>
Source:

IMAGES_LANDING :Array.<string>

Image paths for the landing animation sequence after flight or attack.
Type:
  • Array.<string>
Source:

IMAGES_PREPARE :Array.<string>

Image paths for the prepare animation sequence. Shown before the boss initiates an attack.
Type:
  • Array.<string>
Source:

IMAGES_WALKING :Array.<string>

Image paths for the walking animation.
Type:
  • Array.<string>
Source:

acceleration :number

Vertical acceleration applied to the character (simulates gravity).
Type:
  • number
Source:

attackStart :number

Timestamp when the boss started attacking (ms since epoch).
Type:
  • number
Source:

blinkIntervalMs :number

Interval between blink toggles in milliseconds.
Type:
  • number
Source:

blinkOn :boolean

Current on/off state for the vulnerable blink overlay.
Type:
  • boolean
Source:

canTakeDamage :boolean

Whether the boss can currently take damage. Used to implement invulnerability phases.
Type:
  • boolean
Source:

damage :number

Amount of damage the boss deals.
Type:
  • number
Source:

frameDelay :Object

Frame delays for each animation state of the boss. Includes: dead, hurt, alert, prepare, attack, flying, landing, walking, intro1.
Type:
  • Object
Source:

hasJumpedThisAttack :boolean

One-shot flag to ensure jump during attack happens only once.
Type:
  • boolean
Source:

hasRecentlyAttacked :boolean

Cooldown flag: prevents immediately starting a new attack after the last one.
Type:
  • boolean
Source:

hasRecentlyRetreated :boolean

Cooldown flag: prevents immediately retreating after the last retreat.
Type:
  • boolean
Source:

hasRecentlySpawned :boolean

Cooldown flag: prevents immediately spawning new minions after the last spawn.
Type:
  • boolean
Source:

health :number

Current health of the boss.
Type:
  • number
Source:

height :number

Height of the boss sprite.
Type:
  • number
Source:

introStart :number

Timestamp when the boss intro sequence started (ms since epoch).
Type:
  • number
Source:

isAllowedToWalk :boolean

Whether free walking between minX/maxX is allowed (outside attack/recover locks).
Type:
  • boolean
Source:

isAttacking :boolean

Whether the boss is currently in the attack sequence (locked until it ends).
Type:
  • boolean
Source:

isRecovering :boolean

Whether the boss is currently in the recover sequence (locked until it ends).
Type:
  • boolean
Source:

lastBlinkToggleAt :number

Timestamp of the last blink toggle (ms since epoch).
Type:
  • number
Source:

maxX :number

Right boundary of the boss's allowed horizontal movement range. This value is set dynamically based on the level's end position.
Type:
  • number
Source:

minX :number

Left boundary of the boss's allowed horizontal movement range.
Type:
  • number
Source:

offset :Object

Hitbox offset values to adjust collision detection.
Type:
  • Object
Source:

prepareStart :number

Timestamp when the boss entered the "prepare" state (ms since epoch).
Type:
  • number
Source:

recoverStart :number

Timestamp when the boss started recovering (ms since epoch).
Type:
  • number
Source:

retreatStart :number

Timestamp when boss starts retreating (ms since epoch).
Type:
  • number
Source:

spawningStart :number

Timestamp when boss starts spawning minion chickens (ms since epoch).
Type:
  • number
Source:

speed :number

Movement speed of the boss.
Type:
  • number
Source:

width :number

Width of the boss sprite.
Type:
  • number
Source:

world :World

Reference to the world object containing game entities.
Type:
Source:

x :number

Horizontal starting position of the boss in the level.
Type:
  • number
Source:

y :number

Vertical position of the boss.
Type:
  • number
Source:

Methods

draw(ctx)

Draws the boss on the provided 2D canvas context. Updates visual effects based on state (hurt/vulnerable) and timing. Animation updates are synchronized with frame timing.
Parameters:
Name Type Description
ctx CanvasRenderingContext2D The 2D rendering context.
Source:

drawHurtIndicator(ctx)

Renders the boss with a hue-rotated filter to indicate the hurt state.
Parameters:
Name Type Description
ctx CanvasRenderingContext2D The 2D rendering context.
Source:

drawVulnerableIndicator(ctx, now)

Renders the boss with a timed grayscale/saturation blink effect to indicate the vulnerable state.
Parameters:
Name Type Description
ctx CanvasRenderingContext2D The 2D rendering context.
now number Current timestamp in milliseconds.
Source:

initEndbossLoops()

Initializes the boss's physics and animation systems. Sets up gravity effects synchronized with display refresh rate.
Source:

setMaxX()

Updates `maxX` to match the level's end boundary minus a fixed offset to account for boss sprite width and positioning.
Source:

setWorld(world)

Assigns the current game world to the boss. Also recalculates the maximum allowed horizontal position (`maxX`) based on the level's end boundary.
Parameters:
Name Type Description
world World Reference to the active game world instance.
Source: