2016-05-06 20:31:25 +02:00
|
|
|
# truth or dare tutorial
|
|
|
|
|
|
|
|
### ~avatar avatar
|
|
|
|
|
2016-05-27 00:24:10 +02:00
|
|
|
|
2016-05-06 20:31:25 +02:00
|
|
|
|
|
|
|
The *Truth or dare!* game works as follows: a player spins the BBC micro:bit on the table.
|
|
|
|
When the micro:bit stops spinning, the player pointed by the arrow (displayed on screen) must press the button "A"
|
|
|
|
to see if she has to provide a *truth* or a *dare*.
|
|
|
|
|
|
|
|
### ~
|
|
|
|
|
|
|
|
### Rebuild the game!
|
|
|
|
|
|
|
|
The blocks have been shuffled! Put them back together so that...
|
|
|
|
* an up arrow is displayed when the micro:bit is powered on.
|
|
|
|
* on button `A` is pressed,
|
|
|
|
* randomly display "TRUTH" or "DARE" on the screen
|
|
|
|
* show the up arrow again.
|
|
|
|
|
|
|
|
```shuffle
|
|
|
|
basic.showLeds(`
|
|
|
|
. . # . .
|
|
|
|
. # # # .
|
|
|
|
# # # # #
|
|
|
|
. . # . .
|
|
|
|
. . # . .
|
|
|
|
`)
|
|
|
|
input.onButtonPressed(Button.A, () => {
|
|
|
|
let random = Math.random(2)
|
|
|
|
if (random == 0) {
|
|
|
|
basic.showString("TRUTH")
|
|
|
|
} else {
|
|
|
|
basic.showString("DARE")
|
|
|
|
}
|
|
|
|
basic.showLeds(`
|
|
|
|
. . # . .
|
|
|
|
. # # # .
|
|
|
|
# # # # #
|
|
|
|
. . # . .
|
|
|
|
. . # . .
|
|
|
|
`)
|
|
|
|
})
|
|
|
|
```
|
|
|
|
### Hints and tips
|
|
|
|
Cut out these documentation cards to help you!
|
|
|
|
|
|
|
|
```cards
|
|
|
|
basic.showLeds(`
|
|
|
|
. . # . .
|
|
|
|
. # # # .
|
|
|
|
# . # . #
|
|
|
|
. . # . .
|
|
|
|
. . # . .
|
|
|
|
`);
|
|
|
|
Math.random(2);
|
|
|
|
basic.showString("TRUTH");
|
|
|
|
if (true) {} else {}
|
|
|
|
"TRUTH";
|
|
|
|
0;
|
|
|
|
input.onButtonPressed(Button.A, () => {});
|
|
|
|
```
|
|
|
|
|