Class: PlayerShip

PlayerShip(game, id)

Player 1 ship

Constructor

new PlayerShip(game, id)

Create the ship instance
Parameters:
Name Type Description
game Game The current game instance.
id string Unique DOM element id.
Properties:
Name Type Description
keyState string The current key state
killstreak number The currnet killstreak value
maxHitPoints number Maximum health / hit points this ship can have
upgradeLevel number The level of upgrade for the gun from bonus drops
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:

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()

Overide Sprite default move() method, base movement on the current keyState
Overrides:
Source:

receiveCommand(type, command)

Receive the keydown and keyup events from the main game instance
Parameters:
Name Type Description
type string Keydown or Keyup
command string Left, Right or Fire
Source:

receiveDamage(damage)

Receive damage from enemy bombs, removes upgrades
Parameters:
Name Type Description
damage number Amount of damage received
Overrides:
Source:

receiveHealth(health)

Receive a health bonus
Parameters:
Name Type Description
health number Amount of health / hit points received
Overrides:
Source:

receiveUpgrade(upgradeAmount)

Get a gun upgrade, called from BonusDrop / Gun object
Parameters:
Name Type Description
upgradeAmount number Amount of gun upgrade applied
Source:

removeUpgrade()

Remove the gun upgrade
Source:

reset()

Reset the player to default
Source:

update()

Main player update loop, move, draw etc.
Overrides:
Source: