Class: BonusGun

BonusGun(game, factory, id)

A gun bonus, increases bullet factory max bullets (rapid fire) and changes ship image

Constructor

new BonusGun(game, factory, id)

Create a gun bonus drop
Parameters:
Name Type Description
game SpaceInvaders Current game
factory BonusDropper The bonus dropper factory that created this drop
id string Unique DOM ID string
Author:
Source:

Extends

Methods

collectBonus(player) → {Boolean}

Collect bonus and give it the player - call player receive upgrade.
Parameters:
Name Type Description
player PlayerShip The player who collected this bonus
Overrides:
Source:
Returns:
True or false.
Type
Boolean

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:

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 bonus drop down
Inherited From:
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(player) → {boolean}

Main update loop, move the box down, collision detection with player ship.
Parameters:
Name Type Description
player PlayerShip The player who collected this bonus.
Inherited From:
Source:
Returns:
Success or failure.
Type
boolean