move lessons out of web site

will move select lessons back to "educators" section
This commit is contained in:
Tom Ball
2016-06-14 11:49:58 -04:00
parent a6e6dd8287
commit f4eca66648
184 changed files with 8 additions and 8 deletions

View File

@ -0,0 +1,98 @@
# truth or dare activity
A multi-player game that forces each player to reveal a secret or something funny.
### ~avatar avatar
Welcome! This tutorial will teach how to program a game of truth or dare on the micro:bit. Let's get started!
### ~
Begin by using Show LEDs to create an "up-arrow" image, which will point to someone.
```blocks
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
```
Now let's create a condition to know when button `A` is pressed so that we can display "truth" or "dare" on the micro:bit. We want the BBC micro:bit to randomly choose whether to display "truth" or display "dare". We can use accomplish this by using `pick random (1)`.
```blocks
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
input.onButtonPressed(Button.A, () => {
let random = Math.random(2)
})
```
Now let's display the appropriate message for each scenario of `random`.
```blocks
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
input.onButtonPressed(Button.A, () => {
let random = Math.random(2)
if (random == 0) {
basic.showString("TRUTH")
} else {
basic.showString("DARE")
}
})
```
Notice how the arrow didn't display again after pressing button `A`. Let's add a line of code that displays the arrow again.
```blocks
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
input.onButtonPressed(Button.A, () => {
let random = Math.random(2)
if (random == 0) {
basic.showString("TRUTH")
} else {
basic.showString("DARE")
}
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
})
```
* Run your program: Press button A!
### ~avatar avatar
Excellent, you're ready to continue with the [challenges](/lessons/truth-or-dare/challenges)!
### ~

View File

@ -0,0 +1,104 @@
# truth or dare challenges
A multi-player game that forces each player to reveal a secret or something funny.
## Before we get started
Complete the following [guided tutorial](/lessons/truth-or-dare/activity), and your code should look like this
```blocks
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
input.onButtonPressed(Button.A, () => {
let random = Math.random(2)
if (random == 0) {
basic.showString("TRUTH")
} else {
basic.showString("DARE")
}
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
})
```
### Challenge 1
Let's make the word "DARE" appear a little more often than "TRUTH". Change the line of code with `pick random (1)` to `pick random (2)`.
```blocks
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
input.onButtonPressed(Button.A, () => {
let random = Math.random(3)
if (random == 0) {
basic.showString("TRUTH")
} else {
basic.showString("DARE")
}
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
})
```
### Challenge 2
Instead of just saying "TRUTH" or "DARE", let's sometimes say "SKIP". This would allow the skipped person to spin the micro:bit without completing a truth or dare. Modify the if statement as shown.
``` blocks
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
input.onButtonPressed(Button.A, () => {
let random = Math.random(2)
if (random == 1) {
basic.showString("TRUTH")
} else if (random == 0) {
basic.showString("DARE")
} else {
basic.showString("SKIP")
}
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
})
```
* Run your code to see if it works as expected
### Challenge 3
Add some other messages, such as "TWO DARES" for the micro:bit to show. You will need to modify the parameter inside `pick random (3)` as well as adding another `if` condition.

View File

@ -0,0 +1,42 @@
# truth or dare quiz answers
a multi-player game that forces each player to reveal a secret or something funny.
This is the answer key for the [truth or dare quiz](/lessons/truth-or-dare/quiz).
## 1. Write the code that will randomly return 0 through 3 and stores the value inside a local variable called 'random'.
```blocks
let random = Math.random(4)
```
## 2. Write an if statement that will display the message "TRUTH" on the BBC micro:bit if the local variable 'random' equals 0.
```blocks
let random = Math.random(4)
if (random == 0) {
basic.showString("TRUTH", 150)
}
```
## 3. If the local variable 'random' equals 1, write the string that will be displayed.
DARE
## 4.Write the code that will display this up arrow after pressing button "A".
![](/static/mb/lessons/truth-or-dare-0.png)
```blocks
input.onButtonPressed(Button.A, () => {
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
})
```

View File

@ -0,0 +1,36 @@
# truth or dare quiz
a multi-player game that forces each player to reveal a secret or something funny.
## Name
## Directions
Use this activity document to guide your work in the [truth or dare tutorial](/lessons/truth-or-dare/activity).
Answer the questions while completing the tutorial. Pay attention to the dialogues!
## 1. Write the code that will randomly return 0 through 3 and stores the value inside a local variable called 'random'.
<br/>
<br/>
## 2. Write an if statement that will display the message "TRUTH" on the BBC micro:bit if the local variable 'random' equals 0.
<br/>
<br/>
## 3. If the local variable 'random' equals 1, write the string that will be displayed.
<br/>
<br/>
## 4.Write the code that will display this up arrow after pressing button "A".
![](/static/mb/lessons/truth-or-dare-0.png)
<br/>

View File

@ -0,0 +1,63 @@
# truth or dare tutorial
### ~avatar avatar
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, () => {});
```