Class

Grenade

Grenade(context, player, i)

Grenade projectile handler.
Constructor

# new Grenade(context, player, i)

Create new grenade projectile.
Parameters:
Name Type Description
context CanvasRenderingContext2D the canvas rendering context
player Player the player entity
i number grenade projectile spread index

View Source browser/lib/Ballistics/Grenade.js, line 10

Classes

Grenade

Members

Object

# bounds

bounds - the entity's bounds for intersection.

View Source browser/lib/Ballistics/Grenade.js, line 55

CanvasRenderingContext2D

# context

context - the canvas rendering context

View Source browser/lib/Ballistics/Grenade.js, line 66

number

# frames

frames - counter to control the rendering/update frequency

View Source browser/lib/Ballistics/Grenade.js, line 72

boolean

# markToDelete

markToDelete - determines whether or not the grenade should be rendered/updated

View Source browser/lib/Ballistics/Grenade.js, line 78

number

# radius

radius - the rendered projectile radius size

View Source browser/lib/Ballistics/Grenade.js, line 49

number

# vectorX

vectorX - the projectile vector x-coordinate

View Source browser/lib/Ballistics/Grenade.js, line 25

number

# vectorY

vectorY - the projectile vector y-coordinate

View Source browser/lib/Ballistics/Grenade.js, line 31

number

# x

x - the projectile current x-coordinate

View Source browser/lib/Ballistics/Grenade.js, line 37

number

# y

y - the projectile current y-coordinate

View Source browser/lib/Ballistics/Grenade.js, line 43

Methods

# render(color) → {void}

Render the grenade projectile on the canvas. This is called every frame/repaint to render the bullet. Note that this is an animated entity, therefore the x,y coordinates will change on update.
Parameters:
Name Type Description
color array | string the color(s) of the projectile.

View Source browser/lib/Ballistics/Grenade.js, line 91

void

# update(walls, dropoff) → {void}

Update the projectile data for bounds tracking, collision and cleanup. Updates the grenade's x,y coordinates depending on the vector coordinates and projectile dropoff value, checks frames to ensure the grenade should remain active, and checks for collision against walls to determine if the grenade should remain active. This is called every frame/repaint.
Parameters:
Name Type Default Description
walls Array.<Wall> the rendered walls
dropoff number 25 the projectile dropoff rate

View Source browser/lib/Ballistics/Grenade.js, line 115

void