move lessons out of web site
will move select lessons back to "educators" section
This commit is contained in:
110
olddocs/lessons/spinner/activity.md
Normal file
110
olddocs/lessons/spinner/activity.md
Normal file
@ -0,0 +1,110 @@
|
||||
# spinner activity
|
||||
|
||||
Create an arrow that randomly points to a player.
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
|
||||
|
||||
### ~
|
||||
|
||||
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.
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
|
||||
})
|
||||
```
|
||||
|
||||
Now let's randomly generate a number from 0 to 3 so that we can randomly display an arrow in a given direction.
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let randomArrow = Math.random(4)
|
||||
if (randomArrow == 3) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
|
||||
Now let's handle each of the cases by displaying the appropriate arrow. (Let's display an up arrow if `random arrow` is 0.
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let randomArrow = Math.random(4)
|
||||
if (randomArrow == 3) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow == 2) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
Now let's handle the rest of the cases for `random arrow`.
|
||||
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let randomArrow = Math.random(4)
|
||||
if (randomArrow == 3) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow == 2) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow == 1) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # . .
|
||||
# # # # #
|
||||
. # # . .
|
||||
. . # . .
|
||||
`)
|
||||
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/lessons/spinner/challenges)!
|
||||
|
||||
### ~
|
||||
|
173
olddocs/lessons/spinner/challenges.md
Normal file
173
olddocs/lessons/spinner/challenges.md
Normal file
@ -0,0 +1,173 @@
|
||||
# spinner challenges
|
||||
|
||||
Create an arrow that randomly points to a player.
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following [guided tutorial](/lessons/spinner/activity), your code should look like this:
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let randomArrow = Math.random(4)
|
||||
if (randomArrow == 3) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow == 2) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow == 1) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # . .
|
||||
# # # # #
|
||||
. # # . .
|
||||
. . # . .
|
||||
`)
|
||||
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Modify the random number generator so that it can include new arrows we will create in the next challenge.
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let randomArrow = Math.random(8)
|
||||
if (randomArrow == 3) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow == 2) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow == 1) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # . .
|
||||
# # # # #
|
||||
. # # . .
|
||||
. . # . .
|
||||
`)
|
||||
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
|
||||
* Do **not** run the code yet because it will not work until you have conditions for every random number.
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Let's add more arrows that point diagonally.
|
||||
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let randomArrow = Math.random(8)
|
||||
if (randomArrow == 7) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow == 6) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow == 5) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # . .
|
||||
# # # # #
|
||||
. # # . .
|
||||
. . # . .
|
||||
`)
|
||||
|
||||
}
|
||||
if (randomArrow == 4) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. . . # .
|
||||
# # # # #
|
||||
. . . # .
|
||||
. . # . .
|
||||
`)
|
||||
|
||||
}
|
||||
|
||||
if (randomArrow == 3) {
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # .
|
||||
# # # # .
|
||||
# . . # .
|
||||
. . . . #
|
||||
`)
|
||||
|
||||
}
|
||||
if (randomArrow == 2) {
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
. . # # #
|
||||
. # . # #
|
||||
# . . . #
|
||||
`)
|
||||
|
||||
}
|
||||
if (randomArrow == 1) {
|
||||
basic.showLeds(`
|
||||
# . . . #
|
||||
# # . # .
|
||||
# # # . .
|
||||
# # # # .
|
||||
# # # # #
|
||||
`)
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
|
||||
* Run your code to see if it works as expected
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Add some other arrows if there are more than 8 players.
|
||||
|
56
olddocs/lessons/spinner/quiz-answers.md
Normal file
56
olddocs/lessons/spinner/quiz-answers.md
Normal file
@ -0,0 +1,56 @@
|
||||
# spinner quiz answers
|
||||
|
||||
a spin the BBC micro:bit game with the input on shake.
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [spinner activity](/lessons/spinner/activity).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Write the code that stores a random number between 0 and 3 into a local variable named 'random arrow'.
|
||||
|
||||
<br/>
|
||||
|
||||
```blocks
|
||||
let randomArrow = Math.random(4)
|
||||
```
|
||||
|
||||
## 2. Write the if statement that will display this down arrow from your code. Hint- This occurs if the local variable 'random arrow' returns 1.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
```blocks
|
||||
if (randomArrow == 1) {
|
||||
basic.plotImage(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
```
|
||||
|
||||
## 3. Write the if statement that will display this right arrow. Hint- This occurs if the local variable 'random arrow' returns 2.
|
||||
|
||||

|
||||
|
||||
<br />
|
||||
|
||||
```blocks
|
||||
if (randomArrow == 2) {
|
||||
basic.plotImage(`
|
||||
. . # . .
|
||||
. . # # .
|
||||
# # # # #
|
||||
. . # # .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
```
|
||||
|
28
olddocs/lessons/spinner/quiz.md
Normal file
28
olddocs/lessons/spinner/quiz.md
Normal file
@ -0,0 +1,28 @@
|
||||
# spinner quiz
|
||||
|
||||
a spin the BBC micro:bit game with the input on shake.
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [spinner tutorial](/lessons/spinner/activity).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Write the code that stores a random number between 0 and 3 into a local variable named 'random arrow'.
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Write the if statement that will display this down arrow from your code. Hint- This occurs if the local variable 'random arrow' returns 1.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Write the if statement that will display this right arrow. Hint- This occurs if the local variable 'random arrow' returns 2.
|
||||
|
||||

|
||||
|
||||
<br />
|
||||
|
Reference in New Issue
Block a user