Add game 'life' api reference (#1569)
This commit is contained in:
committed by
Peli de Halleux
parent
a8d64c8ae9
commit
08e9c9c416
33
docs/reference/game/add-life.md
Normal file
33
docs/reference/game/add-life.md
Normal file
@ -0,0 +1,33 @@
|
||||
# add Life
|
||||
|
||||
Increase the number of lives remaining by some amount.
|
||||
|
||||
```sig
|
||||
game.addLife(0)
|
||||
```
|
||||
|
||||
The life count in the game is increased by the number of lives you say.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **life**: a [number](/types/number) to remove from the count.
|
||||
|
||||
## Example #example
|
||||
|
||||
Add `20` more lives to the life count if the player's score reaches `10000` points.
|
||||
|
||||
```blocks
|
||||
let giveLives = true
|
||||
|
||||
if (game.score() > 9999) {
|
||||
if (giveLives) {
|
||||
game.addLife(20)
|
||||
giveLives = false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## See also #seealso
|
||||
|
||||
[set life](/reference/game/set-life),
|
||||
[remove life](/reference/game/remove-life)
|
33
docs/reference/game/remove-life.md
Normal file
33
docs/reference/game/remove-life.md
Normal file
@ -0,0 +1,33 @@
|
||||
# remove Life
|
||||
|
||||
Decrease the number of lives remaining by some amount.
|
||||
|
||||
```sig
|
||||
game.removeLife(0)
|
||||
```
|
||||
|
||||
The life count in the game is decreased by the number of lives you say. If the life count reaches `0` when these lives are removed, then the game is over.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **life**: a [number](/types/number) to remove from the count.
|
||||
|
||||
## Example #example
|
||||
|
||||
Take away `20` lives count if the player's score reaches `10000` points.
|
||||
|
||||
```blocks
|
||||
let giveLives = true
|
||||
|
||||
if (game.score() > 9999) {
|
||||
if (giveLives) {
|
||||
game.removeLife(20)
|
||||
giveLives = false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## See also #seealso
|
||||
|
||||
[set life](/reference/game/set-life),
|
||||
[add life](/reference/game/add-life)
|
26
docs/reference/game/set-life.md
Normal file
26
docs/reference/game/set-life.md
Normal file
@ -0,0 +1,26 @@
|
||||
# set Life
|
||||
|
||||
Set the game life count to this amount.
|
||||
|
||||
```sig
|
||||
game.setLife(0)
|
||||
```
|
||||
|
||||
Your program has a life counter which you can set to record the number of lives remaining for a player in your game. If you set the life count to `0` or less, the game ends.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **value**: a [number](/types/number) to set the life count to.
|
||||
|
||||
## Example #example
|
||||
|
||||
Set the player life count to `9` lives before starting the game.
|
||||
|
||||
```blocks
|
||||
game.setLife(9)
|
||||
```
|
||||
|
||||
## See also #seealso
|
||||
|
||||
[add life](/reference/game/add-life),
|
||||
[remove life](/reference/game/remove-life)
|
Reference in New Issue
Block a user