new BHell_Enemy_Probe()
Probe enemy class. Switches between two states: moving and shooting. In the first state it moves in a straight line towards a random point on screen and never shoots, in the second state it shoots without moving. Due to the moving behavior, it's impossible for it to leave the screen.
Additional parameters:
- shooting: length (in frames) of the shooting phase (the moving phase length depends on the distance from the randomly chosen 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 method. Since no mover is used, the entire moving behaviour is handled here.
- Overrides:
- Source:
updateCharacterFrame()
Updates the charset frame, calculating the correct offsets.
- Inherited From:
- Source: