Constructor
# new Game(bridge, dispatcher, context)
Create a new game instance.
Parameters:
Name | Type | Description |
---|---|---|
bridge |
Object
|
The execution context bridge e.g. "web" or IPC handler. |
dispatcher |
Object
|
The dispatcher object for custom game events. |
context |
Object
|
The canvas rendering context. |
Classes
Members
Methods
# areAllEnemiesDead(entity) → {boolean}
Determine whether or not all enemies are dead based on the enemy entity's
allEnemiesDead property.
Parameters:
Name | Type | Description |
---|---|---|
entity |
Enemy
|
the entity representing the enemy |
boolean
# attach(handler, instance) → {void}
Attach a handler to the game, e.g. a storage handler
Parameters:
Name | Type | Description |
---|---|---|
handler |
string
|
the handler key |
instance |
Object
|
the handler object |
void
# canUpdateEntity(entity) → {boolean}
Determines whether or not the given entity has an update() method implementation.
Parameters:
Name | Type | Description |
---|---|---|
entity |
Object
|
boolean
# createKeyboardMouseControls() → {void}
Create game keyboard-mouse controls and register event listeners.
void
# generateMap(levelIndex) → {this}
Generate a new map based on the passed level index.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
levelIndex |
number
|
0 | the level to generate the map for |
this
# isPlayerDead(entity) → {boolean}
Determine whether or not the player is dead.
Parameters:
Name | Type | Description |
---|---|---|
entity |
Player
|
the entity representing the player |
boolean
# setup(params, loop) → {void}
Setup a new game
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
|
level |
number
|
the level to setup |
loop |
boolean
|
whether or not to start the game loop immediately |
void
# async start(stopped, nextLevel, savedLevel) → {void}
Start the game
Parameters:
Name | Type | Default | Description |
---|---|---|---|
stopped |
boolean
|
whether or not the game is stopped | |
nextLevel |
boolean
|
false | whether or not to start the next level |
savedLevel |
number
|
null
|
null | whether or not to start from a saved level |
void
# toggleStats(panel) → {void}
Toggle the FPS stats counter.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
panel |
number
|
0 | 0 = fps, 1 = ms, 2 = mb, 3+ = custom |
void