new BHell_Enemy_Swirler()
Swirler enemy class. Starshooter with slowly rotating angle.
Additional parameters:
- rotation_angle: rotation speed (in radians per frame) of the bullets' swirl.
- 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 method. Alternates between shooting and cooling down phases. If rnd = true, the shooting angle is changed only during cooldown.
- Overrides:
- Source:
updateCharacterFrame()
Updates the charset frame, calculating the correct offsets.
- Inherited From:
- Source: