Class: EnemyUFO

EnemyUFO(game, fleet, bombFactory, startX, startY, direction, id)

Enemy UFO - has more hitPoints, higher score, different image and movement logic.

Constructor

new EnemyUFO(game, fleet, bombFactory, startX, startY, direction, id)

Create an enemy UFO ship.
Parameters:
Name Type Description
game SpaceInvaders The current game.
fleet EnemyFleet Factory that created this instance.
bombFactory EnemyBombFactory Factory to create enemy bombs.
startX number Starting X position.
startY number Starting Y position.
direction number Direction ship is moving.
id string Unique DOM ID.
Author:
Source:

Extends

Methods

kill()

Kills the enemy ship and starts the death animation loop, updates Score.
Inherited From:
Source:

move() → {boolean}

Overide the default EnemyShip.move() method to give the UFO a different movement pattern Moves back and forwards across the screen, if it's the last enemy on screen it also starts to drop down.
Overrides:
Source:
Returns:
Type
boolean

startBombCountdown()

Reset the bomb counter to a random number, drops 1 each game loop. When it reaches 0 the update loop will trigger a new bomb to be created from the EnemyBombFactory.
Inherited From:
Source:

update() → {boolean}

Main update loop called every animation frame. Dying - If the ship is dying rotate and shrink it until width < 5 Hit Points - If < 0 start the dying process Bomb launch - Check the countdown and if < 0 make new bomb Collision detection - player ship and shieldblock
Inherited From:
Source:
Returns:
Success or failure.
Type
boolean