Class

Enemy

Enemy(spawn, color)

Enemy entity
Constructor

# new Enemy(spawn, color)

Create a new enemy entity.
Parameters:
Name Type Description
spawn Object the enemy spawn coordinates
x number the enemy spawn x-coordinate
y number the enemy spawn y-coordinate
color Object the enemy's color
hands string the enemy hands color
feet string the enemy feet color
torso string the enemy torso color

View Source browser/lib/Entity/Enemy.js, line 11

Classes

Enemy

Members

number

# angle

angle - the entity's angle.

View Source browser/lib/Entity/Enemy.js, line 62

string

# bounding

bounding - the entity's bounding behavior.

View Source browser/lib/Entity/Enemy.js, line 38

Object

# color

Color - entity feet, hands and torso color.

View Source browser/lib/Entity/Enemy.js, line 44

number

# incrementer

incrementer - the entity's speed incrementer.

View Source browser/lib/Entity/Enemy.js, line 74

number

# position

position - the entity's position.

View Source browser/lib/Entity/Enemy.js, line 68

boolean

# sleep

sleep - the entity's render state.

View Source browser/lib/Entity/Enemy.js, line 86

number

# speed

speed - the entity's speed.

View Source browser/lib/Entity/Enemy.js, line 80

string

# type

type - the type of entity.

View Source browser/lib/Entity/Enemy.js, line 32

number

# x

x - the entity's x coordinate.

View Source browser/lib/Entity/Enemy.js, line 50

number

# y

y - the entity's y coordinate.

View Source browser/lib/Entity/Enemy.js, line 56

Methods

# hitByProjectile(projectile, dps, enemies) → {void}

Set the enemy velocity and handle DPS when enemies are hit by projectiles.
Parameters:
Name Type Description
projectile Object the weapon projectile data object
dps number the damage per shot
enemies array the tracked enemy entities

View Source browser/lib/Entity/Enemy.js, line 227

void

# pushAlong(vectorX, vectorY) → {void}

Set the push velocity to push enemies when bumped by entities.
Parameters:
Name Type Description
vectorX number the enemy's vector x-coordinate
vectorY number the enemy's vector y-coordinate

View Source browser/lib/Entity/Enemy.js, line 213

void

# render(context) → {void}

Render the enemy entity on the canvas. This is called every frame/repaint to render the entity. Note that this is an animated entity, therefore the x,y coordinates will change on update.
Parameters:
Name Type Description
context CanvasRenderingContext2D the canvas rendering context

View Source browser/lib/Entity/Enemy.js, line 116

void

# update(game) → {void}

Update the enemy entity for rendering, collision and behaviour. Checks the render state, checks enemy-enemy collision and sets speed/direction accordingly, checks to see if the enemy is dead and updates the tracked entities, updates the enemy entity's bounds, checks for ballistic projectile collisions and sets damage and projectile "pushback" velocity. This is called every frame/repaint.
Parameters:
Name Type Description
game Game the managed game instance

View Source browser/lib/Entity/Enemy.js, line 132

void