Class

Stamina

Stamina(spawn)

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

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

Classes

Stamina

Members

string

# bounding

bounding - the entity's bounding behavior.

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

Object

# bounds

bounds - the entity's bounds for intersection.

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

string

# color

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

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

number

# distance

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

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

number

# glow

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

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

Image

# image

image - the entity's render image.

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

number

# item

item - the entity item.

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

boolean

# markToDelete

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

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

boolean

# sleep

sleep - the entity's render state.

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

string

# type

type - the type of entity.

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

number

# value

value - the entity's in-game value.

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

number

# x

x - the entity's x coordinate.

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

number

# y

y - the entity's y coordinate.

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

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

View Source browser/lib/Entity/Pickup/Stamina.js, line 156

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

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

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

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

void