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

@ -47,6 +47,9 @@ game.startCountdown(10000);
game.gameOver();
game.pause();
game.resume();
game.isGameOver()
game.isRunning();
game.isPaused();
```
## See also
@ -57,4 +60,5 @@ game.resume();
[add score](/reference/game/add-score), [score](/reference/game/score), [set score](/reference/game/set-score),
[set life](/reference/game/set-life), [add life](/reference/game/add-life), [remove life](/reference/game/remove-life),
[start countdown](/reference/game/start-countdown), [game over](/reference/game/game-over),
[pause](/reference/game/pause), [resume](/reference/game/resume)
[pause](/reference/game/pause), [resume](/reference/game/resume),
[is game over](/reference/game/is-game-over,) [is running](/reference/game/is-running), [is paused](/reference/game/is-paused)

View File

@ -0,0 +1,25 @@
# is Game Over
Find out if the game is over or not.
```sig
game.isGameOver()
```
## Returns
* a [boolean](/types/boolean) value that is `true` if the game is over or `false` if not.
# Example
Be kind and give the player some points for trying.
```blocks
if (game.isGameOver() && game.score() < 10) {
game.addScore(10 - game.score())
}
```
## See also
[is running](/reference/game/is-running),
[is paused](/reference/game/is-paused)

View File

@ -0,0 +1,28 @@
# is Paused
Find out if the game is paused or not.
```sig
game.isPaused()
```
## Returns
* a [boolean](/types/boolean) value that is `true` if the game is paused or `false` if not.
## Example
Resume the game if it's paused and button **B** is pressed.
```blocks
input.onButtonPressed(Button.B, function () {
if (game.isPaused()) {
game.resume()
}
})
```
## See also
[is running](/reference/game/is-running),
[is game over](/reference/game/is-game-over)

View File

@ -0,0 +1,28 @@
# is Running
Find out if the game is currently running or not.
```sig
game.isRunning()
```
## Returns
* a [boolean](/types/boolean) value that is `true` if the game is running or `false` if not.
## Example
If the game is currently running, end the game if button **B** is pressed.
```blocks
input.onButtonPressed(Button.B, function () {
if (game.isRunning()) {
game.gameOver()
}
})
```
## See also
[is paused](/reference/game/is-paused),
[is game over](/reference/game/is-game-over)