35 lines
941 B
Markdown
35 lines
941 B
Markdown
|
# spinner activity
|
||
|
|
||
|
Create an arrow that randomly points to a player.
|
||
|
|
||
|
### ~avatar avatar
|
||
|
|
||
|
### @video td/videos/spinner-0
|
||
|
|
||
|
### ~
|
||
|
|
||
|
Welcome! This guided tutorial will teach how to program a script that randomly points to a player. Let's get started!
|
||
|
|
||
|
Let's begin by adding an `on shake` condition to know when the micro:bit is shaken.
|
||
|
|
||
|
![](/static/mb/blocks/lessons/spinner-0.jpg)
|
||
|
|
||
|
Now let's randomly generate a number from 0 to 3 so that we can randomly display an arrow in a given direction.
|
||
|
|
||
|
![](/static/mb/blocks/lessons/spinner-1.jpg)
|
||
|
|
||
|
Now let's handle each of the cases by displaying the appropriate arrow. (Let's display an up arrow if `random arrow` is 0.
|
||
|
|
||
|
![](/static/mb/blocks/lessons/spinner-2.jpg)
|
||
|
|
||
|
Now let's handle the rest of the cases for `random arrow`.
|
||
|
|
||
|
![](/static/mb/blocks/lessons/spinner-3.jpg)
|
||
|
|
||
|
### ~avatar avatar
|
||
|
|
||
|
Excellent, you're ready to continue with the [challenges](/microbit/lessons/spinner/challenges)!
|
||
|
|
||
|
### ~
|
||
|
|