48 lines
1.3 KiB
Markdown
Raw Normal View History

2016-03-25 16:47:20 -07:00
# spinner lesson
a spin the @boardname@ game with the input on shake.
2016-03-25 16:47:20 -07:00
2016-05-26 15:24:10 -07:00
2016-03-25 16:47:20 -07:00
## Topic
If (Conditionals)
## Quick Links
2016-04-13 08:27:45 -07:00
* [activity](/lessons/spinner/activity)
* [challenges](/lessons/spinner/challenges)
* [quiz](/lessons/spinner/quiz)
* [quiz answers](/lessons/spinner/quiz-answers)
2016-03-25 16:47:20 -07:00
## 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
2016-04-04 22:33:13 -07:00
```cards
if (true) {}
2016-03-29 16:17:34 -07:00
let x = 0
2016-04-04 22:33:13 -07:00
input.onGesture(Gesture.Shake, () => {})
2018-06-01 11:42:38 -07:00
Math.randomRange(0, 3)
2016-03-29 16:17:34 -07:00
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`)
```
2016-03-25 16:47:20 -07:00
## Objectives
* learn how to run code when the @boardname@ is shaken, when running code in the web browser, moving the mouse quickly simulates shaking
2016-03-25 16:47:20 -07:00
* 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