Class

Health

Health(spawn)

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

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

Classes

Health

Members

string

# bounding

bounding - the entity's bounding behavior.

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

Object

# bounds

bounds - the entity's bounds for intersection.

View Source browser/lib/Entity/Pickup/Health.js, line 63

string

# color

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

View Source browser/lib/Entity/Pickup/Health.js, line 93

number

# distance

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

View Source browser/lib/Entity/Pickup/Health.js, line 99

number

# glow

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

View Source browser/lib/Entity/Pickup/Health.js, line 87

Image

# image

image - the entity's render image.

View Source browser/lib/Entity/Pickup/Health.js, line 80

number

# item

item - the entity item.

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

boolean

# markToDelete

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

View Source browser/lib/Entity/Pickup/Health.js, line 105

boolean

# sleep

sleep - the entity's render state.

View Source browser/lib/Entity/Pickup/Health.js, line 74

string

# type

type - the type of entity.

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

number

# value

value - the entity's in-game value.

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

number

# x

x - the entity's x coordinate.

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

number

# y

y - the entity's y coordinate.

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

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

View Source browser/lib/Entity/Pickup/Health.js, line 157

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

View Source browser/lib/Entity/Pickup/Health.js, line 119

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

View Source browser/lib/Entity/Pickup/Health.js, line 134

void