2019-12-02 05:58:26 +01:00
|
|
|
# add Score
|
|
|
|
|
|
|
|
Add more to the current score for the game.
|
|
|
|
|
|
|
|
```sig
|
|
|
|
game.addScore(1)
|
|
|
|
```
|
|
|
|
### Parameters
|
|
|
|
|
|
|
|
* a [number](/types/number) that means how much to add to the score. A negative number means to subtract from the score.
|
|
|
|
|
|
|
|
### Examples
|
|
|
|
|
|
|
|
This program is a simple game.
|
|
|
|
Press button ``A`` as much as possible to increase the score.
|
|
|
|
Press ``B`` to display the score and reset the score.
|
|
|
|
|
|
|
|
```blocks
|
2022-04-26 19:28:42 +02:00
|
|
|
input.onButtonEvent(Button.B, ButtonEvent.Down, () => {
|
2019-12-02 05:58:26 +01:00
|
|
|
basic.showNumber(game.score())
|
|
|
|
game.setScore(0)
|
|
|
|
})
|
2022-04-26 19:28:42 +02:00
|
|
|
input.onButtonEvent(Button.A, ButtonEvent.Down, () => {
|
2019-12-02 05:58:26 +01:00
|
|
|
game.addScore(1)
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
### See Also
|
|
|
|
|
|
|
|
[score](/reference/game/score), [set score](/reference/game/set-score), [start countdown](/reference/game/start-countdown)
|