Class: BHell_Enemy_Spline

BHell.BHell_Enemy_Spline()

new BHell_Enemy_Spline()

Spline-based enemy base class. Sets up the moving behavior for every enemy moving in a spline pattern.

Additional parameters:

  • A {x, y}: First spline point,
  • B {x, y}: Second spline point,
  • C {x, y}: Third spline point,
  • D {x, y}: Fourth spline point.
Source:

Extends

Methods

checkCollision(x, y) → {boolean}

Checks if the given coordinates are inside the enemy's hitbox. In case of collision, stores the coordinates into this.lastX and this.lastY (useful for spawning explosions, for example).

Parameters:
Name Type Description
x

X coordinate.

y

Y coordinate.

Inherited From:
Source:
Returns:

true if (x, y) is inside the hitbox.

Type
boolean

crash() → {boolean}

Crashes the enemy, destroying it.

Inherited From:
Source:
Returns:

True if the crash has succeded (e.g. bosses immune to crashing will return false).

Type
boolean

destroy()

Destroys the enemy sprite and removes it from the controller's array of enemies.

Inherited From:
Source:

die()

Awards the killing score and destroys the enemy.

Inherited From:
Source:

hasCrashed(player) → {boolean}

Checks if the enemy has collided with the player.

Parameters:
Name Type Description
player

Player object.

Inherited From:
Source:
Returns:

True if there is a collision.

Type
boolean

hit()

Makes the enemy lose one hit point, possibly killing it.

Inherited From:
Source:

initialize(x, y, image, params, parent, enemyList)

Constructor. Sets the parameters shared between all classes.

Parameters:
Name Type Description
x

X spawning coordinate.

y

Y spawning coordinate.

image

Enemy sprite.

params

Setup parameters.

parent

Container for the enemy's, emitters' and bullets' sprites.

enemyList

Array in which the enemy will be pushed.

Overrides:
Source:

isOutsideMap() → {boolean}

Checks if the enemy has left the map, but only after it has appeared on screen to avoid triggering the enemy's destruction when it's just spawned.

The controller relies on this method to destroy enemies, so enemies which shouldn't be destroyed when leaving the map should always return false.

Inherited From:
Source:
Returns:

True if the enemy has appeared on the screen and is currently outside the screen.

Type
boolean

move()

Moves the enemy and all its emitters, delegating the calculations to its mover.

Inherited From:
Source:

shoot(t)

Enables/disables shooting for every emitter (but only if the player is ready to move).

Parameters:
Name Type Description
t

True to enable shooting, false otherwise.

Inherited From:
Source:

update()

Update function, called every frame.

Inherited From:
Source:

updateCharacterFrame()

Updates the charset frame, calculating the correct offsets.

Inherited From:
Source: