Migrate docs from the other repo

This commit is contained in:
Michal Moskal
2016-03-25 16:47:20 -07:00
parent 38d2cf06d2
commit a08eb53f92
895 changed files with 36888 additions and 0 deletions

View File

@ -0,0 +1,106 @@
# truth or dare activity
a multi-player game that forces each player to reveal a secret or something funny. #docs
To create a new script, go to the [Create Code](/microbit/create-code) page and tap *New Project* under **Touch Develop**.
Begin by plotting an "up-arrow" image, which will point to someone.
```
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`, 400)
```
* Run your program and look at the arrow!
Now let's create a condition to know when button `A` is pressed so that we can display "truth" or "dare" on the BBC micro:bit.
```
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`, 400)
input.onButtonPressed("A", () => {
})
```
We want the BBC micro:bit to randomly choose whether to display "truth" or display "dare". We can use accomplish this by using `math->random(2)`.
```
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`, 400)
input.onButtonPressed("A", () => {
let random = Math.random(2)
})
```
Now let's display the appropriate message for each scenario of `random`.
```
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`, 400)
input.onButtonPressed("A", () => {
let random1 = Math.random(2)
if (random1 == 0) {
basic.showString("TRUTH", 150)
} else {
basic.showString("DARE", 150)
}
})
```
* Run your program: Press button A!
Notice how the arrow didn't display again after pressing button `A`. Let's add a line of code that displays the arrow again.
```
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`, 400)
input.onButtonPressed("A", () => {
let random2 = Math.random(2)
if (random2 == 0) {
basic.showString("TRUTH", 150)
} else {
basic.showString("DARE", 150)
}
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`, 400)
})
```
* Run your program: Press button A!
### ~avatar avatar
Excellent, you're ready to continue with the [challenges](/microbit/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. #docs
## Before we get started
Complete the following guided tutorial:
* [tutorial](/microbit/lessons/truth-or-dare/tutorial)
At the end of the tutorial, click `keep editing`. Your code should look like this:
```
basic.plotImage(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
input.onButtonPressed("A", () => {
let random = Math.random(2)
if (random == 0) {
basic.showString("TRUTH", 150)
} else {
basic.showString("DARE", 150)
}
basic.plotImage(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
})
```
### Challenge 1
Let's make the word "DARE" appear a little more often than "TRUTH". Change the line of code with `math->random(2)` to `math->random(3)`.
```
basic.plotImage(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
input.onButtonPressed("A", () => {
let random1 = Math.random(3) // ***
if (random1 == 0) {
basic.showString("TRUTH", 150)
} else {
basic.showString("DARE", 150)
}
basic.plotImage(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
})
```
### Challenge 2
Instead of just saying "TRUTH" or "DARE", let's sometimes say "SKIP". This would allow the skipped person to spin the BBC micro:bit without completing a truth or dare. Modify the if statement as shown.
```
basic.plotImage(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
input.onButtonPressed("A", () => {
let random2 = Math.random(3)
if (random2 == 0) {
basic.showString("TRUTH", 150) // ***
} else if (random2 == 1) {
basic.showString("DARE", 150) // ***
}
else {
basic.showString("SKIP", 150) // ***
}
basic.plotImage(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
})
```
* Run your code to see if it works as expected
### Challenge 3
Add some other messages, such as "TWO DARES" for the BBC micro:bit to show. You will need to modify the parameter inside `math->random(3)` as well as adding another `if` condition.

View File

@ -0,0 +1,38 @@
# truth or dare quiz answers
a multi-player game that forces each player to reveal a secret or something funny #math #random #docs #shake
This is the answer key for the [truth or dare quiz](/microbit/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'.
```
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.
```
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)
```
basic.plotImage(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
```

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 #math #random #docs #shake
## Name
## Directions
Use this activity document to guide your work in the [truth or dare tutorial](/microbit/lessons/truth-or-dare/tutorial).
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/>