Constructor
# new Stamina(spawn)
Create a new stamina pickup entity.
Parameters:
Name | Type | Description |
---|---|---|
spawn |
Object
|
the stamina pickup item spawn coordinates |
x |
number
|
the stamina pickup item spawn x-coordinate |
y |
number
|
the stamina 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 stamina entity is picked up.
When the player intersects with the entity, the "inject" audio snippet will
play through the AudioFX handler, the player's speed will be boosted by the
entity value for a set number of seconds, 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 stamina 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 stamina 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