Constructor
# new Ammo(spawn)
Create a new ammo pickup entity.
Parameters:
Name | Type | Description |
---|---|---|
spawn |
Object
|
the ammo pickup item spawn coordinates |
x |
number
|
the ammo pickup item spawn x-coordinate |
y |
number
|
the ammo 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 to triggger when the player intersects with the entity.
When the player intersects with the entity, the "reload" audio snippet will
play through the AudioFX handler, the player's ammo or magazines will be
replenished through the Ballistics handler, 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 ammo 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 ammo pickup entity on each frame 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