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 |
Classes
Members
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 |
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 |
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 |
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 |
void