pxt-calliope/docs/reference/game/change-score-by.md

44 lines
975 B
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# Change Score By
The game library
The game library supports simple single-player time-based games. The player will ** add points to score**.
## Block Editor
The code below shows a simple game where the user gets to press the button ``A`` as much times as possible and the score will display on the screen.
![](/static/mb/change-score-by-0.png)
## KindScript
The code below shows a simple game where the user gets to press the button ``A`` as much times as possible in 10 seconds.
```
input.onButtonPressed("A", () => {
game.addScore(1)
})
game.startCountdown(10000)
```
### Score
When a player achieves a goal, you can increase the game score
* add score points to the current score
```
export function addScore(points: number)
```
* get the current score value
```
export function score() : number
```
### Lessons
[bop it](/microbit/lessons/bop-it) | [game of chance](/microbit/lessons/game-of-chance) | [game counter](/microbit/lessons/game-counter)