Extends
Methods
checkCollision(x, y) → {boolean}
Checks if the player collides at given coordinates.
Parameters:
Name | Type | Description |
---|---|---|
x |
X coordinate. |
|
y |
Y coordinate. |
Returns:
True if (x, y) is inside the player's hitbox.
- Type
- boolean
checkGrazing(x, y) → {boolean}
Checks if the player collides at given coordinates.
Parameters:
Name | Type | Description |
---|---|---|
x |
X coordinate. |
|
y |
Y coordinate. |
Returns:
True if (x, y) is inside the player's hitbox.
- Type
- boolean
deltaTo(dx, dy)
Sets a relative destination for the player.
Parameters:
Name | Type | Description |
---|---|---|
dx |
Relative x coordinate of the destination. |
|
dy |
Relative y coordinate of the destination. |
die(t)
If the player is not immortal, destroy it and respawn it.
Parameters:
Name | Type | Description |
---|---|---|
t |
If true, death was caused by a bullet, otherwise by a crash. |
initialize(id, lives, unlimitedBombs, parent)
Constructor. Creates a player from the JSON configuration file.
Parameters:
- name: Player's name,
- sprite: Charset image,
- speed: Player's speed rank (D = 1, C = 2, B = 3, A = 4, S = 5. The actual speed is 2 * rank pixels per frame),
- rate: Player's rate of fire rank (D, C, B, A, S. See
BHell.BHell_Emitter_Factory
). - power: Player's power rank (D, C, B, A, S. See
BHell.BHell_Emitter_Factory
), - bombs: Player's initial stock of bombs (D = 1, C = 2, B = 3, A = 4, S = 5),
- unlocked: If true the player can be used on a stage,
- can_be_bought: If true the player can be bought at the shop,
- price: The player's price at the shop,
- hitbox_w: Width of the player's hitbox,
- hitbox_h: Height of the player's hitbox,
- index: Charset index,
- direction: Charset direction (note: lives displayed on the HUD will always use direction 2),
- frame: Initial charset frame index (0-2),
- animation_speed: Number of updates required for frame change,
- animated: If true the sprite will be animated,
- select_se: Sound effect played when selecting the player,
- spawn_se: Sound effect played when the player has spawned,
- death_se: Sound effect played on player's death,
- victory_se: Sound effect played on stage cleared,
- bomb: Bomb parameters (see
BHell.BHell_Bomb_Base
and derived classes), - emitters: Array of emitters (see
BHell.BHell_Emitter_Base
and derived classes).
Parameters:
Name | Type | Description |
---|---|---|
id |
Id of the player to create. |
|
lives |
Initial number of lives (-1: unlimited). |
|
unlimitedBombs |
If true, the bombs are infinite. |
|
parent |
Container for the sprites. |
- Overrides:
- Source:
launchBomb()
If there are bombs available, launch one.
move()
Moves the player and all its emitters. If the player has just been spawned, moves it towards the starting position, otherwise towards its destination (set with moveTo(x, y) and/or step(h, v) ).
To avoid a death loop during a respawn, the player will wait until the enemy bullets have disappeared from screen (eventually destroying them after a five seconds timeout).
moveTo(x, y)
Sets a destination for the player.
Parameters:
Name | Type | Description |
---|---|---|
x |
X coordinate of the destination. |
|
y |
Y coordinate of the destination. |
shoot(t)
Enables/disables shooting for each helper. If the player has just been spawned, shooting is disabled.
Parameters:
Name | Type | Description |
---|---|---|
t |
True to enable shooting. |
spawn()
Spawn the player outside the screen.
step(h, v)
Sets a destination in steps (multiples of this.speed).
Parameters:
Name | Type | Description |
---|---|---|
h |
Horizontal number of steps. |
|
v |
Vertical number of steps. |
update()
Updates the player's sprite, position and bomb. Awards bonus lives if the score allows it.
- Overrides:
- Source:
updateBonusLives()
Checks if the score has reached the plugin's life_bonus_first and life_bonus_next thresholds and awards bonus lives accordingly.
For example, if the bonus thresholds are set to 20000 and 50000, the player is awarded a life at: 20000 points, 70000 (20000 + 50000), 120000 (20000 + 50000 + 50000), 170000, etc.
updateCharacterFrame()
Updates the charset frame, calculating the correct offsets.
- Inherited From:
- Source:
win()
Plays the victory SE and moves the player to the top of the map.