Class

Ammo

Ammo(spawn)

Ammo pickup item entity
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

View Source browser/lib/Entity/Pickup/Ammo.js, line 12

Classes

Ammo

Members

string

# bounding

bounding - the entity's bounding behavior.

View Source browser/lib/Entity/Pickup/Ammo.js, line 45

Object

# bounds

bounds - the entity's bounds for intersection.

View Source browser/lib/Entity/Pickup/Ammo.js, line 64

string

# color

color - background glow color for the entity's render image.

View Source browser/lib/Entity/Pickup/Ammo.js, line 96

number

# distance

distance - the distance between the player and the entity to trigger behavior.

View Source browser/lib/Entity/Pickup/Ammo.js, line 102

number

# glow

glow - background glow for the entity's render image.

View Source browser/lib/Entity/Pickup/Ammo.js, line 90

Image

# image

image - the entity's render image.

View Source browser/lib/Entity/Pickup/Ammo.js, line 83

number

# item

item - the entity item.

View Source browser/lib/Entity/Pickup/Ammo.js, line 33

boolean

# markToDelete

markToDelete - determines whether the entity should be removed from the game.

View Source browser/lib/Entity/Pickup/Ammo.js, line 108

boolean

# sleep

sleep - the entity's render state.

View Source browser/lib/Entity/Pickup/Ammo.js, line 76

string

# type

type - the type of entity.

View Source browser/lib/Entity/Pickup/Ammo.js, line 27

number

# value

value - the entity's in-game value.

View Source browser/lib/Entity/Pickup/Ammo.js, line 39

number

# x

x - the entity's x coordinate.

View Source browser/lib/Entity/Pickup/Ammo.js, line 51

number

# y

y - the entity's y coordinate.

View Source browser/lib/Entity/Pickup/Ammo.js, line 57

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

View Source browser/lib/Entity/Pickup/Ammo.js, line 160

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

View Source browser/lib/Entity/Pickup/Ammo.js, line 122

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

View Source browser/lib/Entity/Pickup/Ammo.js, line 137

void