Class: PlayerGun

PlayerGun(game, player)

Player bullet factory aka a Gun - controls creation and destruction of bullets

Constructor

new PlayerGun(game, player)

Create a new player gun
Parameters:
Name Type Description
game SpaceInvaders The current game instance
player PlayerShip The player instance
Properties:
Name Type Description
shotsFired number Total shots fired by this gun during current game
shotsHit number Total shots hit by this gun during current game
shotsMissed number Total shots missed by this gun during current game
Author:
Source:

Extends

Members

accuracy

Get the accuracy percentage
Source:

Methods

canFire() → {boolean}

Can the gun fire (can the factory make a new instance at the moment)
Source:
Returns:
Type
boolean

canMake() → {boolean}

Check if we can make a new instance based on maxItems
Inherited From:
Source:
Returns:
Type
boolean

destroy(item) → {Object}

Destroy an instance created by this factory
Parameters:
Name Type Description
item Object The item / instance to destroy
Inherited From:
Source:
Returns:
Returns the instance created
Type
Object

fireGun() → {boolean}

Make a request to fire the gun, won't guarantee a bullet Call the Factory.make() method to create the bullet instance
Source:
Returns:
True is it was fired, false if not
Type
boolean

make() → {boolean}

Make a new Bullet if the gun can fire, overides default Factory.make() method
Overrides:
Source:
Returns:
True is it was made, false if not
Type
boolean

makeItem() → {Bullet}

Makes a new Bullet and returns it, called from Factory.make() method
Overrides:
Source:
Returns:
Return Bullet instance
Type
Bullet

notifyHit() → {boolean}

Recieve a notification a bullet has hit. Called from Bullet
Source:
Returns:
Type
boolean

notifyMiss() → {boolean}

Recieve a notification a bullet has missed. Called from Bullet
Source:
Returns:
Type
boolean

reset()

Destroy all items and reset the data
Inherited From:
Source:

resetCountdown()

Restart the auto make countdown based on max / min delay
Inherited From:
Source:

update()

Main update loop
Inherited From:
Source: