diff --git a/docs/reference/js/lessons/catch-the-egg-game.md b/docs/lessons/catch-the-egg-game.md similarity index 60% rename from docs/reference/js/lessons/catch-the-egg-game.md rename to docs/lessons/catch-the-egg-game.md index fb7a00e5..c0162f4b 100644 --- a/docs/reference/js/lessons/catch-the-egg-game.md +++ b/docs/lessons/catch-the-egg-game.md @@ -10,15 +10,10 @@ Variables ## Quick Links -* [tutorial](/microbit/lessons/catch-the-egg-game/tutorial) * [quiz](/microbit/lessons/catch-the-egg-game/quiz) * [quiz answers](/microbit/lessons/catch-the-egg-game/quiz-answers) * [challenges](/microbit/lessons/catch-the-egg-game/challenges) -## Class - -Year 7 - ## Prior learning/place of lesson in scheme of work Learn how to create a catch the egg game game with **plot**, `led->plot` , **unplot**, `led->unplot`, and **acceleration** `input -> acceleration` to turn on and off LED lights on the LED screen. We will be learning how to create a catch the egg game app using global variables, forever loop, local variable, input acceleration, math min, math max, math random, math mod, if (conditionals), game library as well as simple commands, such as led plot, led unplot, and pause. @@ -52,40 +47,3 @@ Learn how to create a catch the egg game game with **plot**, `led->plot` , **unp * learn how to return the modulus * learn how to show a number of the BBC micro:bit screen * learn how to pause your code for the specified number of milliseconds - -## Progression Pathways / Computational Thinking Framework - -#### Algorithms - -* Designs solutions (algorithms) that use repetition and two-way selection, ie if, then and else.(AL) -* Uses logical reasoning to predict outputs, showing an awareness of inputs (AL) -* Recognises that different solutions exist for the same problem (AL) (AB) Understands that iteration is the repetition of a process such as a loop (AL) -* Represents solutions using a structured notation (AL) (AB) - -#### Programming & Development - -* Creates programs that implement algorithms to achieve given goals (AL) -* Declares and assigns variables(AB) -* Understands the difference between, and appropriately uses if and if, then and else statements(AL) -* Uses a variable and relational operators within a loop to govern termination (AL) (GE) -* Has practical experience of a high-level textual language, including using standard libraries when programming(AB) (AL) -* Uses a range of operators and expressions e.g. Boolean, and applies them in the context of program control. (AL) -* Selects the appropriate data types(AL) (AB - -Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation - -## Activity - -* time: 20 min. -* [tutorial](/microbit/lessons/catch-the-egg-game/tutorial) -* [quiz](/microbit/lessons/catch-the-egg-game/quiz) - -## Extended Activity - -* time: 20 min. -* [challenges](/microbit/lessons/catch-the-egg-game/challenges) - -## Homework - -* Extended Activity: [challenges](/microbit/lessons/catch-the-egg-game/challenges) - diff --git a/docs/reference/js/lessons/catch-the-egg-game/challenges.md b/docs/lessons/catch-the-egg-game/challenges.md similarity index 87% rename from docs/reference/js/lessons/catch-the-egg-game/challenges.md rename to docs/lessons/catch-the-egg-game/challenges.md index 29aa3fba..72fc8b7a 100644 --- a/docs/reference/js/lessons/catch-the-egg-game/challenges.md +++ b/docs/lessons/catch-the-egg-game/challenges.md @@ -4,13 +4,9 @@ Coding challenges for catch the egg game. ## Before we get started -Complete the following guided tutorial: +Your starting code should look like this: -* [tutorial](/microbit/lessons/catch-the-egg-game/tutorial) - -At the end of the tutorial, click `keep editing`. Your code should look like this: - -``` +```blocks let basketX = 2 let eggX = 2 let eggY = 0 @@ -20,7 +16,7 @@ basic.forever(() => { eggY = eggY + 1 led.plot(eggX, eggY) basic.pause(300) - let accX = input.acceleration("x") + let accX = input.acceleration(Dimension.X) basketX = 2 + Math.min(2, Math.max(-2, accX / 200)) led.plot(basketX, 4) if (eggY > 4) { @@ -49,7 +45,7 @@ Now that we know when an egg is caught, we can keep track of the score! We need ### ~ -``` +```blocks let basketX1 = 2 let eggX1 = 2 let eggY1 = 0 @@ -59,8 +55,8 @@ basic.forever(() => { eggY1 = eggY1 + 1 led.plot(eggX1, eggY1) basic.pause(300) - let accX1 = input.acceleration("x") - basketX1 = 2 + Math.min(2, Math.max(-2, accX1 / 200)) + let accX = input.acceleration(Dimension.X) + basketX1 = 2 + Math.min(2, Math.max(-2, accX / 200)) led.plot(basketX1, 4) if (eggY1 > 4) { eggY1 = -1 @@ -87,7 +83,7 @@ Catching eggs gets easier with practice so let's make the eggs fall faster every ### ~ -``` +```blocks let basketX2 = 2 let eggX2 = 2 let eggY2 = 0 @@ -98,7 +94,7 @@ basic.forever(() => { eggY2 = eggY2 + 1 led.plot(eggX2, eggY2) basic.pause(300) - let accX2 = input.acceleration("x") + let accX2 = input.acceleration(Dimension.X) basketX2 = 2 + Math.min(2, Math.max(-2, accX2 / 200)) led.plot(basketX2, 4) if (eggY2 > 4) { @@ -108,7 +104,7 @@ basic.forever(() => { if (eggY2 == 4) { if (basketX2 == eggX2) { game.addScore(1) - if (math.mod(game.score(), 5) == 0) { + if (game.score() %5 == 0) { } } else { game.removeLife(1) @@ -126,7 +122,7 @@ basic.forever(() => { Let's make the egg fall faster by decreasing the amount of time it pauses in each position by decreasing **falling pause** by `25` every 5 catches. Now, instead of pausing for 300 milliseconds we can pause for the value of **falling pause**. -``` +```blocks let basketX3 = 2 let eggX3 = 2 let eggY3 = 0 @@ -137,7 +133,7 @@ basic.forever(() => { eggY3 = eggY3 + 1 led.plot(eggX3, eggY3) basic.pause(300) - let accX3 = input.acceleration("x") + let accX3 = input.acceleration(Dimension.X) basketX3 = 2 + Math.min(2, Math.max(-2, accX3 / 200)) led.plot(basketX3, 4) if (eggY3 > 4) { @@ -147,7 +143,7 @@ basic.forever(() => { if (eggY3 == 4) { if (basketX3 == eggX3) { game.addScore(1) - if (math.mod(game.score(), 5) == 0) { + if (game.score()% 5 == 0) { fallingPause1 = fallingPause1 - 25 // *** } } else { @@ -156,6 +152,7 @@ basic.forever(() => { } basic.pause(fallingPause1) // *** }) + ``` Fantastic! Your game is now ready to show off. diff --git a/docs/reference/js/lessons/catch-the-egg-game/quiz-answers.md b/docs/lessons/catch-the-egg-game/quiz-answers.md similarity index 75% rename from docs/reference/js/lessons/catch-the-egg-game/quiz-answers.md rename to docs/lessons/catch-the-egg-game/quiz-answers.md index 38da8ba0..7af3169d 100644 --- a/docs/reference/js/lessons/catch-the-egg-game/quiz-answers.md +++ b/docs/lessons/catch-the-egg-game/quiz-answers.md @@ -22,7 +22,10 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
-``` +```blocks +let basketX = 2 +let eggX = 2 +let eggY = 0 led.plot(eggX, eggY) led.plot(basketX, 4) ``` @@ -31,28 +34,22 @@ led.plot(basketX, 4)
-``` +```blocks +let basketX = 2 +let eggX = 2 +let eggY = 0 led.unplot(eggX, eggY) eggY = eggY + 1 led.plot(eggX, eggY) ``` -## 4. Write the code that calculates 'basket x' given the variable 'acc x'. +## 4. . Write the code that resets the egg after it has fallen past the bottom of the BBC micro:bit.
-``` -let accX = input.acceleration("x") -basketX = 2 + Math.min(2, Math.max(-2, accX / 200)) -``` - -Note: the first line of code in this answer is optional. - -## 5. Write the code that resets the egg after it has fallen past the bottom of the BBC micro:bit. - -
- -``` +```blocks +let eggX = 2 +let eggY = 0 if (eggY > 4) { eggY = -1 eggX = Math.random(5) diff --git a/docs/reference/js/lessons/catch-the-egg-game/quiz.md b/docs/lessons/catch-the-egg-game/quiz.md similarity index 85% rename from docs/reference/js/lessons/catch-the-egg-game/quiz.md rename to docs/lessons/catch-the-egg-game/quiz.md index 28125f26..339c4fbf 100644 --- a/docs/reference/js/lessons/catch-the-egg-game/quiz.md +++ b/docs/lessons/catch-the-egg-game/quiz.md @@ -24,11 +24,7 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
-## 4. Write the code that calculates 'basket x' given the variable 'acc x'. - -
- -## 5. Write the code that resets the egg after it has fallen past the bottom of the BBC micro:bit. +## 4. Write the code that resets the egg after it has fallen past the bottom of the BBC micro:bit.
diff --git a/docs/lessons/compass/quiz-answers.md b/docs/lessons/compass/quiz-answers.md index 1bfa3303..489251e1 100644 --- a/docs/lessons/compass/quiz-answers.md +++ b/docs/lessons/compass/quiz-answers.md @@ -26,6 +26,7 @@ let degrees = input.compassHeading() ```blocks +let degrees = input.compassHeading() if (degrees < 45) { basic.showString("N", 150) } @@ -35,6 +36,7 @@ if (degrees < 45) { ```blocks +let degrees = input.compassHeading() if (degrees < 135) { basic.showString("E", 150) } @@ -44,6 +46,7 @@ if (degrees < 135) { ```blocks +let degrees = input.compassHeading() if (degrees < 225) { basic.showString("S", 150) } diff --git a/docs/lessons/counter/quiz-answers.md b/docs/lessons/counter/quiz-answers.md index 154cd9bf..2f494d36 100644 --- a/docs/lessons/counter/quiz-answers.md +++ b/docs/lessons/counter/quiz-answers.md @@ -23,10 +23,10 @@ We create a **variable**, `count` to keep track of the current count. The number ## 3. Draw which LEDs are ON after running this code and pressing button "A" once. Explain you chose to draw that number ```blocks -let count_ = 0 +let counts = 0 input.onButtonPressed(Button.A, () => { - count_ = count_ + 1 - basic.showNumber(count, 150) + counts = counts + 1 + basic.showNumber(counts, 150) }) ``` @@ -39,10 +39,10 @@ We are only pressing on button pressed once. So the number to display on the mic ## 4. Draw which LEDs are ON after running this code and pressing button "A" three times. Explain you chose to draw that number ```blocks -count_ = 0 +let counting= 0 input.onButtonPressed(Button.A, () => { - count_ = count_ + 1 - basic.showNumber(count_, 100) + counting = counting + 1 + basic.showNumber(counting, 100) }) ``` diff --git a/docs/lessons/counter/quiz.md b/docs/lessons/counter/quiz.md index 2fb8f3e6..bd8f9d4b 100644 --- a/docs/lessons/counter/quiz.md +++ b/docs/lessons/counter/quiz.md @@ -27,10 +27,10 @@ let count = 0 ## 3. Draw which LEDs are ON after running this code and pressing button "A" once. Explain you chose to draw that number ```blocks -let count_ = 0 +let counts = 0 input.onButtonPressed(Button.A, () => { - count_ = count_ + 1 - basic.showNumber(count_, 100) + counts = counts + 1 + basic.showNumber(counts, 150) }) ``` @@ -41,10 +41,10 @@ input.onButtonPressed(Button.A, () => { ## 4. Draw which LEDs are ON after running this code and pressing button "A" three times. Explain you chose to draw that number ```blocks -count_ = 0 +let counting= 0 input.onButtonPressed(Button.A, () => { - count_ = count_ + 1 - basic.showNumber(count_, 100) + counting = counting + 1 + basic.showNumber(counting, 100) }) ``` diff --git a/docs/lessons/digi-yoyo/quiz-answers.md b/docs/lessons/digi-yoyo/quiz-answers.md index 7df40bf9..4a281b20 100644 --- a/docs/lessons/digi-yoyo/quiz-answers.md +++ b/docs/lessons/digi-yoyo/quiz-answers.md @@ -16,7 +16,7 @@ A loop that repeats code while a condition is true.
-``` +```blocks let count = 0 ``` @@ -26,7 +26,8 @@ let count = 0
-``` +```blocks +let count = 0 while (count < 5) { count = count + 1 } diff --git a/docs/lessons/magic-logo/activity.md b/docs/lessons/magic-logo/activity.md index 96f0f6ec..603e4f88 100644 --- a/docs/lessons/magic-logo/activity.md +++ b/docs/lessons/magic-logo/activity.md @@ -22,7 +22,7 @@ When the micro:bit goes logo up, the code nested under the `on logo up` function ```blocks input.onLogoUp(() => { - basic.showAnimation(` + basic.showLeds(` . . # . . . # # # . # # # # # @@ -31,6 +31,7 @@ input.onLogoUp(() => { `) }) + ``` Run your code and try to turn around the micro:bit to see the **logo up** event in action! diff --git a/docs/lessons/magic-logo/challenges.md b/docs/lessons/magic-logo/challenges.md index 864ac13a..6ce04b0e 100644 --- a/docs/lessons/magic-logo/challenges.md +++ b/docs/lessons/magic-logo/challenges.md @@ -8,7 +8,7 @@ Complete the [magic logo](/microbit/lessons/magic-logo/activity) activity and yo ```blocks input.onLogoUp(() => { - basic.showAnimation(` + basic.showLeds(` . . # . . . # # # . # # # # # @@ -28,7 +28,7 @@ How about when the logo is down? We should display an arrow pointing downward! ```blocks input.onLogoUp(() => { - basic.showAnimation(` + basic.showLeds(` . . # . . . # # # . # # # # # @@ -37,7 +37,7 @@ input.onLogoUp(() => { `) }) input.onLogoDown(() => { - basic.showAnimation(` + basic.showLeds(` . . # . . . . # . . # # # # # diff --git a/docs/lessons/magic-logo/quiz-answers.md b/docs/lessons/magic-logo/quiz-answers.md index 4aac9fa7..0a087f5e 100644 --- a/docs/lessons/magic-logo/quiz-answers.md +++ b/docs/lessons/magic-logo/quiz-answers.md @@ -44,7 +44,7 @@ input.onLogoUp(() => { ```blocks input.onLogoDown(() => { - basic.plotImage(` + basic.showLeds(` . . # . . . . # . . # # # # # diff --git a/docs/lessons/rotation-animation/quiz-answers.md b/docs/lessons/rotation-animation/quiz-answers.md index 51fc2f41..38d86043 100644 --- a/docs/lessons/rotation-animation/quiz-answers.md +++ b/docs/lessons/rotation-animation/quiz-answers.md @@ -4,34 +4,50 @@ Learn how to create a rotating image with a while loop. #image #loop #while #do This is the answer key for the [rotation animation quiz](/microbit/lessons/rotation-animation/quiz). -## 1. What is a "global variable"? +## 1. What is a " variable"? -Answers may vary. A global variable is a place where you can store data so that you can use it later in your code. +Answers may vary. A variable is a place where you can store data so that you can use it later in your code. -## 2. Consider the following directions +## 2. Write the code to create a ** variable** called `foo` that stores a boolean and initialize it to **false**. -Write the code to create a **global variable** called `foo` that stores a boolean and initialize it to **false**. -``` -rotating = true + +```blocks +let rotating = true; ``` -## 3. Consider the following code +## 3. Explain what this line of code does. -``` +```blocks +let rotating = true; while (rotating) { + basic.showLeds(` + . . . . . + . . . . . + . . # . . + . . . . . + . . . . . + `) + basic.showLeds(` + . . . . . + . . . . . + . . . . . + . . . . . + . . . . . + `) } + ``` -Explain what this line of code does. +
-It is a **while** loop that will be executed only if the **global variable** called `rotating` is **true**. +It is a **while** loop that will be executed only if the ** variable** called `rotating` is **true**. -## 4. Consider the following code +## 4. If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed. Explain why that particular area is shaded. -``` +```blocks basic.showAnimation(` # . . . . . . # . . . . . . # . . . . . . # . . . . . # . . . . . # . . . . . . @@ -41,7 +57,7 @@ basic.showAnimation(` `, 400) ``` -If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed. Explain why that particular area is shaded. + ![](/static/mb/lessons/rotation-animation-0.png) diff --git a/docs/lessons/rotation-animation/quiz.md b/docs/lessons/rotation-animation/quiz.md index 35f47452..b9505fab 100644 --- a/docs/lessons/rotation-animation/quiz.md +++ b/docs/lessons/rotation-animation/quiz.md @@ -10,26 +10,42 @@ Use this activity document to guide your work in the [rotation animation tutoria Answer the questions while completing the tutorial. Pay attention to the dialogues! -## 1. What is a "global variable"? +## 1. What is a " variable"?
-## 2. Write the code to create a global variable called foo that stores a boolean and initialize it to false. +## 2. Write the code to create a variable called foo that stores a boolean and initialize it to false.
-## 3. Explain why you use a while loop with a global variable +## 3. Explain why you use a while loop with a variable -``` +```blocks +let rotating = true; while (rotating) { + basic.showLeds(` + . . . . . + . . . . . + . . # . . + . . . . . + . . . . . + `) + basic.showLeds(` + . . . . . + . . . . . + . . . . . + . . . . . + . . . . . + `) } + ```
## 4. Draw the areas on the micro:bits to illustrate the code below. Explain why you chose to draw in those areas. -``` +```blocks basic.showAnimation(` # . . . . . . # . . . . . . # . . . . . . # . . . . . # . . . . . # . . . . . . diff --git a/docs/lessons/smiley/activity.md b/docs/lessons/smiley/activity.md index 2777881c..87b7b1a9 100644 --- a/docs/lessons/smiley/activity.md +++ b/docs/lessons/smiley/activity.md @@ -13,14 +13,14 @@ Welcome! This tutorial will help you make a smiley face blink. Let's get started Create an animation with an image displaying a smiley face and the next image with no LEDs lit up. This will make it look like the smiley face is blinking as the display switches between images. ```blocks -basic.showAnimation(` +basic.showLeds(` . # . # . . # . # . . . . . . # . . . # . # # # . `) -basic.showAnimation(` +basic.showLeds(` . . . . . . . . . . . . . . . diff --git a/docs/lessons/smiley/challenges.md b/docs/lessons/smiley/challenges.md index f875843f..171de366 100644 --- a/docs/lessons/smiley/challenges.md +++ b/docs/lessons/smiley/challenges.md @@ -8,14 +8,14 @@ Complete the [smiley activity](/microbit/lessons/smiley/activity) and your code ```blocks -basic.showAnimation(` +basic.showLeds(` . # . # . . # . # . . . . . . # . . . # . # # # . `) -basic.showAnimation(` +basic.showLeds(` . . . . . . . . . . . . . . . @@ -33,14 +33,14 @@ Let's make add code that will run when button A is pressed! ```blocks -basic.showAnimation(` +basic.showLeds(` . # . # . . # . # . . . . . . # . . . # . # # # . `) -basic.showAnimation(` +basic.showLeds(` . . . . . . . . . . . . . . . @@ -59,14 +59,14 @@ input.onButtonPressed(Button.A, () => { Now, we want to show a frowny face when this button is pressed. Let's show the LEDs. ```blocks -basic.showAnimation(` +basic.showLeds(` . # . # . . # . # . . . . . . # . . . # . # # # . `) -basic.showAnimation(` +basic.showLeds(` . . . . . . . . . . . . . . . @@ -74,7 +74,7 @@ basic.showAnimation(` . . . . . `) input.onButtonPressed(Button.A, () => { - basic.showAnimation(` + basic.showLeds(` . # . # . . # . # . . . . . . diff --git a/docs/lessons/snowflake-fall/activity.md b/docs/lessons/snowflake-fall/activity.md index f9065309..04d6d8d9 100644 --- a/docs/lessons/snowflake-fall/activity.md +++ b/docs/lessons/snowflake-fall/activity.md @@ -51,7 +51,7 @@ basic.forever(() => { . . # . . `) }) -```blocks +``` Run your code in the simulator or download it to your BBC micro:bit to see what happens! diff --git a/docs/lessons/snowflake-fall/challenges.md b/docs/lessons/snowflake-fall/challenges.md index 26f80a46..00d057cb 100644 --- a/docs/lessons/snowflake-fall/challenges.md +++ b/docs/lessons/snowflake-fall/challenges.md @@ -6,25 +6,59 @@ Coding challenges for snowflake fall. Complete the [snowflake fall](/microbit/lessons/snowflake-fall/activity) activity and your code will look like this: -![](/static/mb/blocks/lessons/snowflake-fall-1.jpg) +```blocks +basic.forever(() => { + basic.showLeds(` + . . . . . + . . # . . + . # # # . + . . # . . + . . . . . + `) + basic.showLeds(` + . . # . . + . # . # . + # . . . # + . # . # . + . . # . . + `) +}) +``` ### Challenge 1 ### @video td/videos/snowflake-fall-1 -Let's begin creating our falling effect by adding another snowflake with `show LEDs` that displays a different snowflake pattern after the first one. We need 2 frames in the new animation that display both the first and the second snowflake images. - -![](/static/mb/blocks/lessons/snowflake-fall-2.jpg) - -* Run your program to see the cool animation. - -### Challenge 2 - -### @video td/videos/snowflake-fall-2 - To finalize our snowflake fall, let's add a different snowflake pattern. -![](/static/mb/blocks/lessons/snowflake-fall-3.jpg) +```blocks + +basic.forever(() => { + basic.showLeds(` + . . . . . + . . # . . + . # # # . + . . # . . + . . . . . + `) + basic.showLeds(` + . . # . . + . # . # . + # . . . # + . # . # . + . . # . . + `) + basic.showLeds(` + . # . # . + # # # # # + . # . # . + # # # # # + . # . # . + `) +}) + +``` + * Run your program and see if it works. diff --git a/docs/lessons/snowflake-fall/quiz-answers.md b/docs/lessons/snowflake-fall/quiz-answers.md index 3cb3855e..e1c82bd6 100644 --- a/docs/lessons/snowflake-fall/quiz-answers.md +++ b/docs/lessons/snowflake-fall/quiz-answers.md @@ -28,7 +28,24 @@ basic.forever(() => { ![](/static/mb/lessons/snowflake-fall-0.png) -![](/static/mb/blocks/lessons/snowflake-fall-5.png) +```blocks +basic.forever(() => { + basic.showLeds(` + . . . . . + . . # . . + . # # # . + . . # . . + . . . . . + `); + basic.showLeds(` + . . . . . + . . . . . + . . . . . + . . . . . + . . . . . + `) +}); +``` ## 4. Write the code for a forever loop and show LEDS for these images! @@ -36,5 +53,21 @@ basic.forever(() => { ![](/static/mb/lessons/snowflake-fall-2.png) -![](/static/mb/blocks/lessons/snowflake-fall-6.png) - +```blocks +basic.forever(() => { + basic.showLeds(` + . . . . . + . . # . . + . # # # . + . . # . . + . . . . . + `); + basic.showLeds(` + # # # # # + # # . # # + # . # . # + # # . # # + # # # # # + `) +}); +``` \ No newline at end of file diff --git a/docs/lessons/spinner/activity.md b/docs/lessons/spinner/activity.md index f1f9aaec..6cd85a86 100644 --- a/docs/lessons/spinner/activity.md +++ b/docs/lessons/spinner/activity.md @@ -12,19 +12,95 @@ Welcome! This guided tutorial will teach how to program a script that randomly p Let's begin by adding an `on shake` condition to know when the micro:bit is shaken. -![](/static/mb/blocks/lessons/spinner-0.jpg) +```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. -![](/static/mb/blocks/lessons/spinner-1.jpg) +```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. -![](/static/mb/blocks/lessons/spinner-2.jpg) +```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`. -![](/static/mb/blocks/lessons/spinner-3.jpg) + +```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 diff --git a/docs/lessons/spinner/challenges.md b/docs/lessons/spinner/challenges.md index 6b468fc7..81aee108 100644 --- a/docs/lessons/spinner/challenges.md +++ b/docs/lessons/spinner/challenges.md @@ -6,21 +6,164 @@ Create an arrow that randomly points to a player. Complete the following [guided tutorial](/microbit/lessons/spinner/activity), your code should look like this: -![](/static/mb/blocks/lessons/spinner-3.jpg) +```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. -![](/static/mb/blocks/lessons/spinner-4.jpg) +```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 four more arrows that point diagonally. +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(` + # . . . # + # # . # . + # # # . . + # # # # . + # # # # # + `) + + } + +}) + +``` -![](/static/mb/blocks/lessons/spinner-5.jpg) * Run your code to see if it works as expected diff --git a/docs/lessons/zoomer/quiz-answers.md b/docs/lessons/zoomer/quiz-answers.md index fb6995ac..d9e24e1c 100644 --- a/docs/lessons/zoomer/quiz-answers.md +++ b/docs/lessons/zoomer/quiz-answers.md @@ -14,7 +14,7 @@ Write the line of code to measure the acceleration and then store in it a variab
-``` +```blocks let accX_ = input.acceleration("x") ``` @@ -26,9 +26,9 @@ After storing the acceleration in a variable, write the code to show acceleratio
-``` +```blocks let accX = input.acceleration("x") -basic.showNumber(accX_, 150) +basic.showNumber(accX, 150) ``` Note: make sure the same variable name ("acc x" in this case) is the same in both lines of code.. diff --git a/docs/reference/js/lessons/catch-the-egg.md b/docs/reference/js/lessons/catch-the-egg.md deleted file mode 100644 index 6b0a9d84..00000000 --- a/docs/reference/js/lessons/catch-the-egg.md +++ /dev/null @@ -1,8 +0,0 @@ -# catch the egg - -Programming a game of 'catch the egg' using the accelerometer in Touch Develop #docs #functions #var - -Programming a game of 'catch the egg' using the accelerometer - -* [tutorial](/microbit/lessons/catch-the-egg-game/tutorial) -* [challenges](/microbit/lessons/catch-the-egg/challenges)