Class: EnemyBomb

EnemyBomb(game, bombFactory, droppedBy, id)

Individual enemy bomb.

Constructor

new EnemyBomb(game, bombFactory, droppedBy, id)

Make a new enemy bomb.
Parameters:
Name Type Description
game SpaceInvaders The current game instance.
bombFactory EnemyBombFactory The bomb factory that created this bomb.
droppedBy EnemyShip The enemy ship that dropped this bomb.
id string Unique HTML DOM id.
Author:
Source:

Extends

Methods

destroyDomElement() → {boolean}

Remove this DOM element from the HTML document.
Inherited From:
Source:
Returns:
Type
boolean

detectCollisionWith(sprite) → {boolean}

Detect collision between two sprites. Checks for any gaps between the sprites.
Parameters:
Name Type Description
sprite Sprite The sprite we are checking for a collision with.
Inherited From:
Source:
Returns:
True if collision
Type
boolean

draw()

Update the DOM Element style properties to move the sprite
Inherited From:
Source:

inflictDamage(target) → {boolean}

Send damage to the target object via the receiveDamage method.
Parameters:
Name Type Description
target PlayerShip | ShieldBlock The object the bomb hit, player ship or shield.
Source:
Returns:
Type
boolean

inMe(x, y) → {boolean}

Is the x, y game world point inside this sprite.
Parameters:
Name Type Description
x number The X position.
y number The Y position.
Inherited From:
Source:
Returns:
True if inside
Type
boolean

makeDomElement(css) → {boolean}

Make the DOM element for this sprite inside the Game element.
Parameters:
Name Type Description
css string CSS style to apply to the element.
Inherited From:
Source:
Returns:
Type
boolean

makeDomElementInside(parent, css) → {boolean}

Make the DOM element for this sprite inside the supplied element and assign it the supplied css class.
Parameters:
Name Type Description
parent Sprite The parent sprite or object with a DOM element.
css string CSS style to apply to the element.
Inherited From:
Source:
Returns:
Type
boolean

move()

Move the bomb down.
Overrides:
Source:

receiveDamage(damage) → {boolean}

Receive damage on this sprite, what happens when hit points < 0 is handled by the class that extended the sprite class. If hit points < 0 returns True to indicate this was a kill
Parameters:
Name Type Description
damage number The amount of damage received.
Inherited From:
Source:
Returns:
True if this was a kill shot
Type
boolean

receiveHealth(health) → {boolean}

Receive health
Parameters:
Name Type Description
health number The amount of health / hit points received.
Inherited From:
Source:
Returns:
Type
boolean

update() → {boolean}

Update the movement and perform collision detection for player ship and shield grid.
Overrides:
Source:
Returns:
Type
boolean