Constructor
# new Health(spawn)
Create a new health pickup entity.
Parameters:
Name | Type | Description |
---|---|---|
spawn |
Object
|
the health pickup item spawn coordinates |
x |
number
|
the health pickup item spawn x-coordinate |
y |
number
|
the health pickup item spawn y-coordinate |
Classes
Members
boolean
# markToDelete
markToDelete - determines whether the entity should be removed from the game.
Methods
# pickup(game) → {void}
Defines the behaviour when health entity is picked up.
When the player intersects with the entity, the "inject" audio snippet will
play through the AudioFX handler, the player's health will be replenished by
the entity value or they will gain a medkit if their health is full, and then
the entity will be marked for deletion, upon which it wil be removed from the
canvas on the next frame/repaint.
Parameters:
Name | Type | Description |
---|---|---|
game |
Game
|
the managed game instance |
void
# render(context) → {void}
Render the health pickup entity on the canvas.
This is called every frame/repaint to render the entity. Note that this is
a statically-placed entity, therefore the x,y coordinates will not change on
update.
Parameters:
Name | Type | Description |
---|---|---|
context |
CanvasRenderingContext2D
|
the canvas rendering context |
void
# update(game) → {void}
Update the health pickup entity for rendering, collision and behaviour.
This is called every frame/repaint, upon which collision vectors are calculated to
determine if the player and the entity intersect, if they do, then the entity's pickup
method is executed as a callback.
Parameters:
Name | Type | Description |
---|---|---|
game |
Game
|
the managed game instance |
void