new BHell_Enemy_Blocker()
Blocker enemy class. It moves horizontally trying to stop the player (as long as its speed can keep up) and slowly creeps towards the bottom, shooting downwards.
Added parameters:
- vspeed: vertical speed (in pixels per frame).
- 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()
Move method. Instead of using a mover, the behaviour is entirely handled here.
- Overrides:
- 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: