fixing references / snippets

cleanup "snippets" compilation state
This commit is contained in:
Peli de Halleux
2016-10-22 21:29:31 -07:00
parent fcefe1ed36
commit bd1536132d
51 changed files with 94 additions and 91 deletions

View File

@ -6,43 +6,43 @@ a game similar to "Simon Says" with the BBC micro:bit.
Complete the following guided tutorial. Your code should look like this:
```blocks
newAction() // ***
```typescript
let action = 0;
function newAction() {}
input.onButtonPressed(Button.A, () => {
if (action == 0) {
game.addScore(1) // ***
newAction() // ***
game.addScore(1);
newAction();
}
}) // ***
})
input.onLogoDown(() => {
if (action == 1) {
game.addScore(1) // ***
newAction()
game.addScore(1);
newAction();
}
})
input.onGesture(Gesture.Shake, () => {
if (action == 2) {
game.addScore(1)
newAction()
game.addScore(1);
newAction();
}
})
input.onButtonPressed(Button.B, () => {
basic.showNumber(game.score(), 150) // ***
basic.pause(2000) // ***
newAction() // ***
basic.showNumber(game.score(), 150);
basic.pause(2000);
newAction();
})
```
### Challenge 1
Now let's add some more types of instructions for the player to follow. Let's add `PRESS PIN 0`. Change the global variable `action` to `math->random(4)` so that we can add a new **IF** statement that checks if `action=3`. If it does, display instructions to press pin 0.
Now let's add some more types of instructions for the player to follow. Let's add `PRESS PIN 0`.
Change the global variable `action` to `math->random(4)` so that we can add a new **IF** statement that checks if `action=3`. If it does, display instructions to press pin 0.
```blocks
/**
* {highlight}
*/
```typescript
let action = 0;
export function newAction() {
action = Math.random(4) // ***
action = Math.random(4)
if (action == 0) {
basic.showString("PUSH A", 150) // ***
}
@ -62,19 +62,22 @@ export function newAction() {
Now let's implement `PRESS PIN 0` in the main. Create a condition of `input->on pin pressed("P0")` that will add one to the score and calls the method `new action`.
```blocks
// **. . .**
```typescript
let action = 0;
export function newAction() {
// ...
}
input.onButtonPressed(Button.B, () => {
basic.showNumber(game.score(), 150) // ***
basic.pause(2000) // ***
newAction() // ***
}) // ***
basic.showNumber(game.score(), 150)
basic.pause(2000)
newAction()
})
input.onPinPressed(TouchPin.P0, () => {
if (action == 3) {
game.addScore(1) // ***
newAction() // ***
game.addScore(1)
newAction()
}
}) // ***
})
```
### Challenge 3

View File

@ -88,5 +88,5 @@ Have fun reviewing your simulation and analyze the acceleration by chart the Exc
* Display acceleration with y or z using plot bar graph by changing acceleration from "x" to "y" or "z"
```package
microbit-radio
radio
```

View File

@ -29,6 +29,7 @@ Write the line of code that will display the string "puppy" using `data->coll`.
<br/>
```blocks
let coll: string[] = []
basic.showString(coll[0], 150)
```
@ -46,6 +47,7 @@ Write the line of code that will display the string "cat" using `data->coll`.
<br/>
```blocks
let coll: string[] = []
basic.showString(coll[2], 150)
```

View File

@ -44,5 +44,5 @@ radio.onDataReceived(() => { })
* learn how to pause your code for the specified number of milliseconds
```package
microbit-radio
radio
```

View File

@ -164,5 +164,5 @@ Connect the second micro:bit to your computer using your USB cable and run the p
The first person and second person take turns jumping in the “y” direction while the other player uses the micro:bit to track the results on the micro:bit!
```package
microbit-radio
radio
```

View File

@ -35,5 +35,5 @@ radio.receiveNumber();
* learn how to read the connector value as analog as a value comprised between 0 and 1023
```package
microbit-radio
radio
```

View File

@ -196,5 +196,5 @@ Let's select Style 10 as an example.
* Review and analyze the actual micro:bit device acceleration data on Excel
```package
microbit-radio
radio
```

View File

@ -25,8 +25,9 @@ let randomArrow = Math.random(4)
<br/>
```blocks
let randomArrow = Math.random(4);
if (randomArrow == 1) {
basic.plotImage(`
basic.showLeds(`
. . # . .
. . # . .
# # # # #
@ -43,8 +44,9 @@ if (randomArrow == 1) {
<br />
```blocks
let randomArrow = Math.random(4);
if (randomArrow == 2) {
basic.plotImage(`
basic.showLeds(`
. . # . .
. . # # .
# # # # #