Add game state boolean ref docs (#1694)

* Add game state boolean doc refs

* Add check for _img validity

* JS guru tricks
This commit is contained in:
Galen Nickel
2018-12-02 20:11:17 -08:00
committed by GitHub
parent dda488c08f
commit 55e5125449
7 changed files with 100 additions and 13 deletions

View File

@ -250,13 +250,12 @@ namespace game {
}
/**
* Gets a value indicating if the game is still running. Returns `false` if game over.
* Indicates if the game is still running. Returns `false` if the game is over or paused.
*/
//% weight=5 help=game/isrunning
//% blockId=game_isrunning block="is running?" blockGap=8
//% weight=5 help=game/is-running
//% blockId=game_isrunning block="is running" blockGap=8
export function isRunning(): boolean {
let running: boolean;
return !_isGameOver;
return !_isGameOver && !_paused && !!_img;
}
/**
@ -271,10 +270,10 @@ namespace game {
}
/**
* Indicates if the game is display the game over sequence.
* Indicates if the game is over and displaying the game over sequence.
*/
//% weight=7 help=game/isgameover
//% blockId=game_isgameover block="is game over?" blockGap=8
//% weight=7 help=game/is-game-over
//% blockId=game_isgameover block="is game over" blockGap=8
export function isGameOver(): boolean {
return _isGameOver;
}
@ -282,8 +281,8 @@ namespace game {
/**
* Indicates if the game rendering is paused to allow other animations
*/
//% weight=6 help=game/ispaused
//% blockId=game_ispaused block="is paused?" blockGap=8
//% weight=6 help=game/is-paused
//% blockId=game_ispaused block="is paused" blockGap=8
export function isPaused(): boolean {
return _paused;
}