pxt-calliope/docs/lessons/game-counter.md

38 lines
904 B
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# game counter lesson
Learn how to create a counter with with on button pressed. #show #number #screen #number #math #docs
### @video td/videos/counter-0
## Topic
Game Library
## Quick Links
* [activity](/microbit/lessons/game-counter/activity)
* [challenges](/microbit/lessons/game-counter/challenges)
## Prior learning/place of lesson in scheme of work
Learn how to create game blocks to keep track of the current score. We will be learning how to create a game using the blocks called `add points to score`, `score` as well as simple commands such as on button pressed and show number.
## Documentation
2016-03-30 00:59:00 +02:00
```docs
game.addScore(1)
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
input.onButtonPressed(Button.A, () => {
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
})
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
basic.showNumber(0)
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
```
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
## Objectives
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
* learn how arithmetic operators operate on numbers and return a number
* learn how to run code when an input button is pressed
* learn how to show a score on the LED screen