updated lessons
This commit is contained in:
parent
8ede130a95
commit
612142a292
@ -59,9 +59,9 @@ Overview of lessons for the BBC micro:bit.
|
|||||||
* [Telegraph](/microbit/lessons/telegraph), play the telegraph game between two BBC micro:bits
|
* [Telegraph](/microbit/lessons/telegraph), play the telegraph game between two BBC micro:bits
|
||||||
|
|
||||||
## Advanced
|
## Advanced
|
||||||
|
* [Speed Button](/microbit/lessons/speed-button), code a speed game with running time
|
||||||
* [Hero](/microbit/lessons/hero), reconstruct the classic arcade game pac man with the BBC micro:bit
|
* [Hero](/microbit/lessons/hero), reconstruct the classic arcade game pac man with the BBC micro:bit
|
||||||
* [Catch the Egg](/microbit/lessons/catch-the-egg-game), reconstruct the classic game of Catch the Egg with the BBC micro:bit
|
* [Catch the Egg](/microbit/lessons/catch-the-egg-game), catch falling eggs in a basket with an acceleration controller
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
### @section full
|
### @section full
|
||||||
|
@ -6,11 +6,9 @@ Coding challenges for the speed button tutorial. #docs
|
|||||||
|
|
||||||
Complete the following guided tutorial:
|
Complete the following guided tutorial:
|
||||||
|
|
||||||
* [tutorial](/microbit/lessons/speed-button/tutorial)
|
Your starting code should look like this:
|
||||||
|
|
||||||
At the end of the tutorial, click `keep editing`. Your code should look like this:
|
```blocks
|
||||||
|
|
||||||
```
|
|
||||||
let counter = 0
|
let counter = 0
|
||||||
let fastPress = false
|
let fastPress = false
|
||||||
input.onButtonPressed(Button.A, () => {
|
input.onButtonPressed(Button.A, () => {
|
||||||
@ -22,7 +20,7 @@ input.onButtonPressed(Button.A, () => {
|
|||||||
|
|
||||||
We need to know when the user has hit button `A` 15 times. The user wins when he/she is able to accomplish this in less than 5000 milliseconds (5 seconds). We can check for both conditions by using an `and` operator. When using an `and` operator, both conditions need to be true in order for the condition to be true.
|
We need to know when the user has hit button `A` 15 times. The user wins when he/she is able to accomplish this in less than 5000 milliseconds (5 seconds). We can check for both conditions by using an `and` operator. When using an `and` operator, both conditions need to be true in order for the condition to be true.
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
let counter1 = 0
|
let counter1 = 0
|
||||||
let fastPress1 = false
|
let fastPress1 = false
|
||||||
input.onButtonPressed(Button.A, () => {
|
input.onButtonPressed(Button.A, () => {
|
||||||
@ -34,7 +32,7 @@ input.onButtonPressed(Button.A, () => {
|
|||||||
|
|
||||||
Next, if the user has won, let's set our boolean to true. This indicates that he or she has won.
|
Next, if the user has won, let's set our boolean to true. This indicates that he or she has won.
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
let counter2 = 0
|
let counter2 = 0
|
||||||
let fastPress2 = false
|
let fastPress2 = false
|
||||||
input.onButtonPressed(Button.A, () => {
|
input.onButtonPressed(Button.A, () => {
|
||||||
@ -49,7 +47,7 @@ input.onButtonPressed(Button.A, () => {
|
|||||||
|
|
||||||
We want to set `fastPress` to false if the user was too slow. To do so, we need another condition to see if the user took more than 5000 milliseconds (5 seconds). In the `if` statement, set `fastPress` to false.
|
We want to set `fastPress` to false if the user was too slow. To do so, we need another condition to see if the user took more than 5000 milliseconds (5 seconds). In the `if` statement, set `fastPress` to false.
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
let counter3 = 0
|
let counter3 = 0
|
||||||
let fastPress3 = false
|
let fastPress3 = false
|
||||||
input.onButtonPressed(Button.A, () => {
|
input.onButtonPressed(Button.A, () => {
|
||||||
@ -69,7 +67,7 @@ input.onButtonPressed(Button.A, () => {
|
|||||||
|
|
||||||
Now let's display if the user won or lost. To do so, we need to check the status of `fastPress` when the game is finished, and then show the correct message.
|
Now let's display if the user won or lost. To do so, we need to check the status of `fastPress` when the game is finished, and then show the correct message.
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
let counter4 = 0
|
let counter4 = 0
|
||||||
let fastPress4 = false
|
let fastPress4 = false
|
||||||
input.onButtonPressed(Button.A, () => {
|
input.onButtonPressed(Button.A, () => {
|
@ -12,7 +12,7 @@ A variable that is available throughout your main function.
|
|||||||
|
|
||||||
## 2. If the rectangle below represents the BBC micro:bit, shade the area that shows the value of the variable count.
|
## 2. If the rectangle below represents the BBC micro:bit, shade the area that shows the value of the variable count.
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
let count = 0
|
let count = 0
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ let count = 0
|
|||||||
|
|
||||||
## 3. If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed after two button presses on Button A. Explain why that particular area is shaded.
|
## 3. If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed after two button presses on Button A. Explain why that particular area is shaded.
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
let count_ = 0
|
let count_ = 0
|
||||||
input.onButtonPressed(Button.A, () => {
|
input.onButtonPressed(Button.A, () => {
|
||||||
count_ = count_ + 1
|
count_ = count_ + 1
|
||||||
@ -36,7 +36,7 @@ After two button presses, **count** will be equal to 2.
|
|||||||
|
|
||||||
## 5. If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed after five button presses on Button A. Explain why that particular area is shaded.
|
## 5. If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed after five button presses on Button A. Explain why that particular area is shaded.
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
count_ = 0
|
count_ = 0
|
||||||
input.onButtonPressed(Button.A, () => {
|
input.onButtonPressed(Button.A, () => {
|
||||||
count_ = count_ + 1
|
count_ = count_ + 1
|
@ -14,7 +14,7 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
|
|||||||
|
|
||||||
## 2. Draw which LEDs show the number being stored as a global variable called count
|
## 2. Draw which LEDs show the number being stored as a global variable called count
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
let count = 0
|
let count = 0
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ let count = 0
|
|||||||
|
|
||||||
## 3. Draw which LED is ON after running this code and pressing Button A twice. Explain why you chose to draw that number
|
## 3. Draw which LED is ON after running this code and pressing Button A twice. Explain why you chose to draw that number
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
let count_ = 0
|
let count_ = 0
|
||||||
input.onButtonPressed(Button.A, () => {
|
input.onButtonPressed(Button.A, () => {
|
||||||
count_ = count_ + 1
|
count_ = count_ + 1
|
||||||
@ -36,7 +36,7 @@ input.onButtonPressed(Button.A, () => {
|
|||||||
|
|
||||||
## 4. Draw which LED is ON after running this code and pressing Button A five times. Explain why you chose to draw that number.
|
## 4. Draw which LED is ON after running this code and pressing Button A five times. Explain why you chose to draw that number.
|
||||||
|
|
||||||
```
|
```blocks
|
||||||
count_ = 0
|
count_ = 0
|
||||||
input.onButtonPressed(Button.A, () => {
|
input.onButtonPressed(Button.A, () => {
|
||||||
count_ = count_ + 1
|
count_ = count_ + 1
|
Loading…
Reference in New Issue
Block a user