pxt-calliope/docs/lessons/spinner.md
2016-04-01 16:22:47 -07:00

53 lines
1.4 KiB
Markdown

# spinner lesson
a spin the BBC micro:bit game with the input on shake.
### @video td/videos/spinner-0
## Topic
If (Conditionals)
## Quick Links
* [activity](/microbit/lessons/spinner/activity)
* [challenges](/microbit/lessons/spinner/challenges)
* [quiz](/microbit/lessons/spinner/quiz)
* [quiz answers](/microbit/lessons/spinner/quiz-answers)
## Prior learning/place of lesson in scheme of work
Learn how to use an if statement to run code run code depending on whether a condition is true or not. We will be learning how to create a die with If statements, On Shake, Variables, Assignment Operator, Pick Random and Show LEDs.
## Documentation
```docs
if (true) {
}
let x = 0
input.onGesture(Gesture.Shake, () => {
})
Math.random(3)
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`)
```
## Objectives
* learn how to run code when the BBC micro:bit is shaken, when running code in the web browser, moving the mouse quickly simulates shaking
* learn how to create a local variable as a place where you can store and retrieve data
* learn how the assignment operator is used to declare a new local variable
* learn how to declare a new local variable or update the value of a variable
* learn how to return a random number
* learn how to conditionally run code depending on whether a condition is true or not
* learn how to show an image on the LED screen