pxt-microbit 6.1.2 → 6.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/built/hexcache/{a205d05d10c4848e8a9454ddb6b085235213690f446c18ac8eb610d69c8c0d98.hex → 02e118276d7ad61fd1e7913a87f10d8ffee34a65b883e7b8efce291712f45092.hex} +10499 -10480
- package/built/hexcache/{1a29827806d7ca2a8e55b95c99194503f7fdfaa45a3ebfcc25cda8e5c1e51824.hex → 56661ceac4d8678e416df6f0cb117457b277232c45f0a578a9298d26f8eaba35.hex} +9914 -9895
- package/built/hexcache/62b44871df9fdf64381631c44888c831f0e73d4a7a6221dc1b91aea7bd9aa76a.hex +14523 -0
- package/built/hexcache/f4b5733caac6970862b68d159aad886755259b131a794060ce8075730c534b64.hex +13996 -0
- package/built/sim-strings.json +1 -1
- package/built/sim.d.ts +10 -0
- package/built/sim.js +133 -23
- package/built/target.js +1 -1
- package/built/target.json +1 -1
- package/built/targetlight.json +1 -1
- package/built/web/react-common-authcode.css +1 -1
- package/built/web/react-common-multiplayer.css +1 -1
- package/built/web/react-common-skillmap.css +1 -1
- package/built/web/rtlreact-common-authcode.css +1 -1
- package/built/web/rtlreact-common-multiplayer.css +1 -1
- package/built/web/rtlreact-common-skillmap.css +1 -1
- package/built/web/rtlsemantic.css +3 -3
- package/built/web/semantic.css +3 -3
- package/docs/extensions.md +16 -0
- package/docs/projects/7-seconds.md +8 -8
- package/docs/projects/carnival/button-points.md +118 -0
- package/docs/projects/carnival/circuit-win.md +107 -0
- package/docs/projects/carnival/shake-lose.md +97 -0
- package/docs/projects/coin-flipper.md +8 -8
- package/docs/projects/compass.md +12 -17
- package/docs/projects/dice.md +15 -8
- package/docs/projects/flashing-heart.md +4 -4
- package/docs/projects/heads-guess.md +10 -10
- package/docs/projects/hot-potato.md +8 -8
- package/docs/projects/love-meter.md +12 -6
- package/docs/projects/magic-button-trick.md +2 -4
- package/docs/projects/multi-dice.md +7 -7
- package/docs/projects/name-tag.md +5 -5
- package/docs/projects/rock-paper-scissors-v2.md +13 -13
- package/docs/projects/rock-paper-scissors.md +12 -12
- package/docs/projects/smiley-buttons.md +7 -7
- package/docs/projects/v2-blow-away.md +17 -13
- package/docs/projects/v2-cat-napping.md +18 -14
- package/docs/projects/v2-clap-lights.md +19 -10
- package/docs/projects/v2-countdown.md +16 -8
- package/docs/projects/v2-morse-chat.md +13 -13
- package/docs/projects/v2-pet-hamster.md +26 -13
- package/docs/reference/input/compass-heading.md +9 -5
- package/docs/reference/input/magnetic-force.md +16 -8
- package/docs/static/orglogowide.png +0 -0
- package/docs/translate.md +4 -4
- package/package.json +3 -3
- package/pxtarget.json +12 -18
- package/sim/public/simulator.html +45 -0
- package/targetconfig.json +6 -2
- package/built/hexcache/215f0a9c22dcecda497365fd42b85e341eda40aa40d2d69d427265c77cc5f004.hex +0 -14333
- package/built/hexcache/704323c8559a596aec81e104e6d4bb8ae10bafd9dec77489fbb082158b23a4e4.hex +0 -14853
- package/sim/public/parts/.gitignore +0 -5
package/docs/extensions.md
CHANGED
|
@@ -307,6 +307,10 @@ Check out [the accessories pages on microbit.org](https://microbit.org/buy/acces
|
|
|
307
307
|
"name": "gator:UV UV Light sensor",
|
|
308
308
|
"url":"/pkg/sparkfun/pxt-gator-UV",
|
|
309
309
|
"cardType": "package"
|
|
310
|
+
}, {
|
|
311
|
+
"name": "Sensirion SEN55 (Air Quality) Sensor",
|
|
312
|
+
"url":"/pkg/bsiever/pxt-sen55",
|
|
313
|
+
"cardType": "package"
|
|
310
314
|
}]
|
|
311
315
|
```
|
|
312
316
|
|
|
@@ -427,6 +431,10 @@ Check out [the accessories pages on microbit.org](https://microbit.org/buy/acces
|
|
|
427
431
|
"name": "Joy-IT Joy-Pi Advanced",
|
|
428
432
|
"url":"/pkg/joy-it/pxt-RB-JoyPi-Advanced",
|
|
429
433
|
"cardType": "package"
|
|
434
|
+
}, {
|
|
435
|
+
"name": "FWD Edu Climate Action Kit Gen. 2 Kit",
|
|
436
|
+
"url":"/pkg/climate-action-kits/pxt-fwd-edu",
|
|
437
|
+
"cardType": "package"
|
|
430
438
|
}]
|
|
431
439
|
```
|
|
432
440
|
|
|
@@ -680,6 +688,10 @@ Check out [the accessories pages on microbit.org](https://microbit.org/buy/acces
|
|
|
680
688
|
"name": "Elecfreaks Cutebot",
|
|
681
689
|
"url":"/pkg/elecfreaks/pxt-cutebot",
|
|
682
690
|
"cardType": "package"
|
|
691
|
+
}, {
|
|
692
|
+
"name": "Elecfreaks Cutebot Pro",
|
|
693
|
+
"url":"/pkg/elecfreaks/pxt-cutebot-pro",
|
|
694
|
+
"cardType": "package"
|
|
683
695
|
}, {
|
|
684
696
|
"name": "Kittenbot RobotBit",
|
|
685
697
|
"url":"/pkg/kittenbot/pxt-robotbit",
|
|
@@ -912,6 +924,10 @@ Check out [the accessories pages on microbit.org](https://microbit.org/buy/acces
|
|
|
912
924
|
## Utilities
|
|
913
925
|
```codecard
|
|
914
926
|
[{
|
|
927
|
+
"name": "Morse Code",
|
|
928
|
+
"url": "/pkg/bsiever/pxt-morse",
|
|
929
|
+
"cardType": "package"
|
|
930
|
+
}, {
|
|
915
931
|
"name": "Button clicks",
|
|
916
932
|
"url": "/pkg/bsiever/microbit-pxt-clicks",
|
|
917
933
|
"cardType": "package"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 7 seconds game
|
|
2
2
|
|
|
3
|
-
## Introduction @unplugged
|
|
3
|
+
## {Introduction @unplugged}
|
|
4
4
|
|
|
5
5
|
The goal of this game is press a button after **exactly** 7 seconds!
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ The goal of this game is press a button after **exactly** 7 seconds!
|
|
|
8
8
|
|
|
9
9
|
This game is inspired from the [flipping panckakes game](https://www.elecfreaks.com/blog/post/flipping-pancakes-microbit-game.html).
|
|
10
10
|
|
|
11
|
-
## Step 1
|
|
11
|
+
## {Step 1}
|
|
12
12
|
|
|
13
13
|
The player starts the timer by pressing button **A**. We'll run the code run code when ``||input:button A is pressed||``.
|
|
14
14
|
|
|
@@ -18,7 +18,7 @@ input.onButtonPressed(Button.A, function () {
|
|
|
18
18
|
})
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
## Step 2
|
|
21
|
+
## {Step 2}
|
|
22
22
|
|
|
23
23
|
We need to remember the time when the button was pressed so that we can compute the elapsed time later on.
|
|
24
24
|
Add code to store the ``||input:running time||`` in a ``||variables:start||`` variable.
|
|
@@ -31,7 +31,7 @@ input.onButtonPressed(Button.A, function () {
|
|
|
31
31
|
})
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
## Step 3
|
|
34
|
+
## {Step 3}
|
|
35
35
|
|
|
36
36
|
Show something on the screen so that the user knows that the timer has started...
|
|
37
37
|
|
|
@@ -44,7 +44,7 @@ input.onButtonPressed(Button.A, function () {
|
|
|
44
44
|
})
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
## Step 4
|
|
47
|
+
## {Step 4}
|
|
48
48
|
|
|
49
49
|
The player stops the timer by pressing button **B**. Add the code to run code when ``||input:button B is pressed||``.
|
|
50
50
|
|
|
@@ -54,7 +54,7 @@ input.onButtonPressed(Button.B, function () {
|
|
|
54
54
|
})
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
## Step 5
|
|
57
|
+
## {Step 5}
|
|
58
58
|
|
|
59
59
|
Compute the elapsed time as ``||input:running time||`` ``||math:minus||`` ``||variables:start||`` and store it into a new variable ``||variables:elapsed||``.
|
|
60
60
|
|
|
@@ -67,7 +67,7 @@ input.onButtonPressed(Button.B, function () {
|
|
|
67
67
|
})
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
## Step 6
|
|
70
|
+
## {Step 6}
|
|
71
71
|
|
|
72
72
|
Compute the ``||variables:score||`` of the game as the ``||math:absolute value||`` of the ``||math:difference||`` of ``||variables:elapsed||`` time from 7 seconds, which is 7000 milliseconds.
|
|
73
73
|
|
|
@@ -82,7 +82,7 @@ input.onButtonPressed(Button.B, function () {
|
|
|
82
82
|
})
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
## Step 7
|
|
85
|
+
## {Step 7}
|
|
86
86
|
|
|
87
87
|
Display the score on the screen and your game is ready!
|
|
88
88
|
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Add Points with Buttons
|
|
2
|
+
### @explicitHints true
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Introduction @showdialog
|
|
6
|
+
|
|
7
|
+
Let's add a point to your score when a button is pressed on the @boardname@!
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## {Step 2}
|
|
13
|
+
|
|
14
|
+
We 'll start by adding code to the ``||input:on button pressed||``<br/>
|
|
15
|
+
container already in the workspace.
|
|
16
|
+
|
|
17
|
+
💡 _You can click the arrow next to ``||input:A||`` and change to another button if you prefer._
|
|
18
|
+
|
|
19
|
+
#### ~ tutorialhint
|
|
20
|
+
```blocks
|
|
21
|
+
input.onButtonPressed(Button.A, function() { })
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## {Step 3}
|
|
25
|
+
|
|
26
|
+
Open the ``||variables:Variables||`` category<br/>
|
|
27
|
+
and drag ``||variables:change [score] by [1]||``<br/>
|
|
28
|
+
into the empty ``||input:on button [A] [pressed]||``.
|
|
29
|
+
|
|
30
|
+
#### ~ tutorialhint
|
|
31
|
+
```blocks
|
|
32
|
+
input.onButtonPressed(Button.A, function() {
|
|
33
|
+
score += 1
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## {Step 4}
|
|
38
|
+
|
|
39
|
+
Update the LEDs after you change the score by opening the <br/>
|
|
40
|
+
``||basic:Basic||`` category and dragging ``||basic:show number [score]||``<br/>
|
|
41
|
+
into **the end** of the ``||input:on button [A] [pressed]||`` container already in the workspace.
|
|
42
|
+
|
|
43
|
+
#### ~ tutorialhint
|
|
44
|
+
```blocks
|
|
45
|
+
pins.onPulsed(DigitalPin.P0, PulseValue.High, function () {
|
|
46
|
+
score += 1
|
|
47
|
+
basic.showNumber(score)
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## {Step 4}
|
|
53
|
+
|
|
54
|
+
Click the A button in the simulator to give your code a try.
|
|
55
|
+
|
|
56
|
+
You should see the score go up each time the button is pressed.
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
## {Step 5}
|
|
60
|
+
|
|
61
|
+
**Add sound effects.**
|
|
62
|
+
|
|
63
|
+
Open the ``||music:Music||`` category and <br/>
|
|
64
|
+
drag ``||music:play [〰️] [in background]||`` <br/>
|
|
65
|
+
into **the end** of the ``||input:on button [A] [pressed]||`` container in the workspace.
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
#### ~ tutorialhint
|
|
69
|
+
```blocks
|
|
70
|
+
pins.onPulsed(DigitalPin.P0, PulseValue.High, function () {
|
|
71
|
+
score += 1
|
|
72
|
+
basic.showNumber(score)
|
|
73
|
+
music._playDefaultBackground(music.createSoundExpression(WaveShape.Square, 400, 600, 255, 0, 100, SoundExpressionEffect.Warble, InterpolationCurve.Linear), music.PlaybackMode.InBackground)
|
|
74
|
+
})
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
## {Step 6}
|
|
79
|
+
|
|
80
|
+
**Test again by pressing A**
|
|
81
|
+
|
|
82
|
+
Your program should play a sound and increase your points with each click.
|
|
83
|
+
|
|
84
|
+
💡 _You may need to unmute the simulator to hear your music._
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
## {Step 7}
|
|
89
|
+
|
|
90
|
+
If you have a @boardname@ connected, click ``|Download|`` and transfer your code.
|
|
91
|
+
|
|
92
|
+
Now you're ready to attach your @boardname@ to your project and try it out!
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
```blockconfig.global
|
|
97
|
+
music._playDefaultBackground(music.createSoundExpression(WaveShape.Square, 400, 600, 255, 0, 100, SoundExpressionEffect.Warble, InterpolationCurve.Linear), music.PlaybackMode.InBackground)
|
|
98
|
+
basic.showNumber(score)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
```template
|
|
103
|
+
input.onButtonPressed(Button.A, function() {})
|
|
104
|
+
|
|
105
|
+
let score = 0
|
|
106
|
+
score = 0
|
|
107
|
+
basic.showNumber(score)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
```ghost
|
|
111
|
+
basic.showIcon(IconNames.Yes)
|
|
112
|
+
score += 1
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
let score = 0
|
|
116
|
+
basic.showNumber(score)
|
|
117
|
+
|
|
118
|
+
```
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Connect a Circuit to Win
|
|
2
|
+
### @explicitHints true
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Introduction @showdialog
|
|
6
|
+
|
|
7
|
+
Let's detect a WIN when a circuit is completed on the @boardname@!
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## {Step 2}
|
|
13
|
+
|
|
14
|
+
We 'll start by adding code to the ``||input:on pin [P0] [pressed]||``<br/>
|
|
15
|
+
container already in the workspace.
|
|
16
|
+
|
|
17
|
+
💡 _You can click the arrow next to ``||input:P0||`` and change it to another pin if you prefer._
|
|
18
|
+
|
|
19
|
+
#### ~ tutorialhint
|
|
20
|
+
```blocks
|
|
21
|
+
input.onPinPressed(TouchPin.P0, function () {})
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## {Step 3}
|
|
25
|
+
|
|
26
|
+
Open the ``||basic:Basic||`` category<br/>
|
|
27
|
+
and drag ``||basic:show string ["WIN!"]||``<br/>
|
|
28
|
+
into the empty ``||input:on pin [P0] [pressed]||`` container to display a message.
|
|
29
|
+
|
|
30
|
+
#### ~ tutorialhint
|
|
31
|
+
```blocks
|
|
32
|
+
input.onPinPressed(TouchPin.P0, function () {
|
|
33
|
+
basic.showString("WIN!")
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## {Step 4}
|
|
40
|
+
|
|
41
|
+
Click the pin marked **0** in the simulator to give your code a try.
|
|
42
|
+
|
|
43
|
+

|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## {Step 5}
|
|
47
|
+
|
|
48
|
+
**Add some drama with music.**
|
|
49
|
+
|
|
50
|
+
Open the ``||music:Music||`` category and <br/>
|
|
51
|
+
drag ``||music:play [melody] [in background]||`` <br/>
|
|
52
|
+
into **the top** of the ``||input:on pin [P0] [pressed]||`` container in the workspace.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
#### ~ tutorialhint
|
|
56
|
+
```blocks
|
|
57
|
+
input.onPinPressed(TouchPin.P0, function () {
|
|
58
|
+
music._playDefaultBackground(music.builtInPlayableMelody(Melodies.Dadadadum), music.PlaybackMode.InBackground)
|
|
59
|
+
basic.showString("WIN!")
|
|
60
|
+
})
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## {Step 6}
|
|
65
|
+
|
|
66
|
+
**Test again by clicking P0 in the simulator**
|
|
67
|
+
|
|
68
|
+
Your program should play a song and scroll the word "WIN!".
|
|
69
|
+
|
|
70
|
+
💡 _You may need to unmute the simulator to hear your music._
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## {Step 7}
|
|
75
|
+
|
|
76
|
+
If you have a @boardname@ connected, click ``|Download|`` and transfer your code.
|
|
77
|
+
|
|
78
|
+
Now you're ready to attach your @boardname@ to your project and try it out!
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
💡 _Note that the **pin pressed** block requires the pin to be pressed **and** released before it will trigger._
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
```blockconfig.global
|
|
87
|
+
music.play(music.builtinPlayableSoundEffect(soundExpression.soaring), music.PlaybackMode.InBackground)
|
|
88
|
+
basic.showString("WIN!")
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
```template
|
|
93
|
+
input.onPinPressed(TouchPin.P0, function () { })
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```ghost
|
|
97
|
+
basic.showIcon(IconNames.Yes)
|
|
98
|
+
input.onButtonPressed(Button.A, function () {
|
|
99
|
+
music.play(music.builtinPlayableSoundEffect(soundExpression.sad), music.PlaybackMode.InBackground)
|
|
100
|
+
music._playDefaultBackground(music.builtInPlayableMelody(Melodies.Funeral), music.PlaybackMode.InBackground)
|
|
101
|
+
basic.showString("Loss")
|
|
102
|
+
})
|
|
103
|
+
input.onPinPressed(TouchPin.P0, function () {
|
|
104
|
+
music.play(music.builtinPlayableSoundEffect(soundExpression.sad), music.PlaybackMode.InBackground)
|
|
105
|
+
basic.showString("WIN!")
|
|
106
|
+
})
|
|
107
|
+
```
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Shake or Fall to Lose
|
|
2
|
+
### @explicitHints true
|
|
3
|
+
|
|
4
|
+
## Introduction @showdialog
|
|
5
|
+
|
|
6
|
+
Let's detect a loss when the @boardname@ shakes or drops!
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
## {Step 2}
|
|
11
|
+
|
|
12
|
+
We 'll start by adding code to the ``||input:on shake||`` container already in the workspace.
|
|
13
|
+
|
|
14
|
+
💡 _You can also click the arrow next to ``||input:shake||`` and change the action to ``||input:free fall||`` or another event in the library._
|
|
15
|
+
|
|
16
|
+
#### ~ tutorialhint
|
|
17
|
+
```blocks
|
|
18
|
+
input.onGesture(Gesture.Shake, function() { })
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## {Step 3}
|
|
22
|
+
|
|
23
|
+
Open the ``||basic:Basic||`` category<br/>
|
|
24
|
+
and drag ``||basic:show string ["Loss"]||``<br/>
|
|
25
|
+
into the empty ``||input:on shake||`` container to display a message.
|
|
26
|
+
|
|
27
|
+
#### ~ tutorialhint
|
|
28
|
+
```blocks
|
|
29
|
+
input.onGesture(Gesture.Shake, function() {
|
|
30
|
+
basic.showString("Loss")
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## {Step 4}
|
|
37
|
+
|
|
38
|
+
Click the little white circle in the simulator next to **SHAKE** to give your code a try.
|
|
39
|
+
|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## {Step 5}
|
|
44
|
+
|
|
45
|
+
**Add some drama with music.**
|
|
46
|
+
|
|
47
|
+
Open the ``||music:Music||`` category and <br/>
|
|
48
|
+
drag ``||music:play [melody] [in background]||`` <br/>
|
|
49
|
+
into **the top** of the ``||input:on shake||`` container in the workspace.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
#### ~ tutorialhint
|
|
53
|
+
```blocks
|
|
54
|
+
input.onGesture(Gesture.Shake, function() {
|
|
55
|
+
music._playDefaultBackground(music.builtInPlayableMelody(Melodies.Dadadadum), music.PlaybackMode.InBackground)
|
|
56
|
+
basic.showString("Loss")
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
## {Step 6}
|
|
62
|
+
|
|
63
|
+
**Test again by clicking ⚬SHAKE**
|
|
64
|
+
|
|
65
|
+
Your program should play a song and scroll the word "Loss".
|
|
66
|
+
|
|
67
|
+
💡 _You may need to unmute the simulator to hear your music._
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## {Step 7}
|
|
72
|
+
|
|
73
|
+
If you have a @boardname@ connected, click ``|Download|`` and transfer your code.
|
|
74
|
+
|
|
75
|
+
Now you're ready to attach your @boardname@ to your project and try it out!
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
```blockconfig.global
|
|
80
|
+
music._playDefaultBackground(music.builtInPlayableMelody(Melodies.Funeral), music.PlaybackMode.InBackground)
|
|
81
|
+
basic.showString("Loss")
|
|
82
|
+
basic.showIcon(IconNames.Yes)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
```template
|
|
87
|
+
input.onGesture(Gesture.Shake, function() {})
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```ghost
|
|
91
|
+
basic.showIcon(IconNames.Yes)
|
|
92
|
+
input.onButtonPressed(Button.A, function () {
|
|
93
|
+
music.play(music.builtinPlayableSoundEffect(soundExpression.sad), music.PlaybackMode.InBackground)
|
|
94
|
+
music._playDefaultBackground(music.builtInPlayableMelody(Melodies.Funeral), music.PlaybackMode.InBackground)
|
|
95
|
+
basic.showString("Loss")
|
|
96
|
+
})
|
|
97
|
+
```
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Coin Flipper
|
|
2
2
|
|
|
3
|
-
## Introduction @unplugged
|
|
3
|
+
## {Introduction @unplugged}
|
|
4
4
|
|
|
5
5
|
Let's create a coin flipping program to simulate a real coin toss. We'll use icon images to represent a ``heads`` or ``tails`` result.
|
|
6
6
|
|
|
7
7
|

|
|
8
8
|
|
|
9
|
-
## Step 1
|
|
9
|
+
## {Step 1}
|
|
10
10
|
|
|
11
11
|
Let's start with the ``||input:on button A pressed||`` block on the Workspace. We'll put our coin flipping code in here.
|
|
12
12
|
|
|
@@ -15,7 +15,7 @@ input.onButtonPressed(Button.A, function() {
|
|
|
15
15
|
})
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
## Step 2
|
|
18
|
+
## {Step 2}
|
|
19
19
|
|
|
20
20
|
Grab an ``||logic:if else||`` block and set it inside ``||input:on button A pressed||``. Put a ``||Math:pick random true or false||`` into the ``||logic:if||`` as its condition.
|
|
21
21
|
|
|
@@ -29,7 +29,7 @@ input.onButtonPressed(Button.A, function() {
|
|
|
29
29
|
})
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
## Step 3
|
|
32
|
+
## {Step 3}
|
|
33
33
|
|
|
34
34
|
Now, put a ``||basic:show icon||`` block inside both the ``||logic:if||`` and the ``||logic:else||``. Pick images to mean ``heads`` and ``tails``.
|
|
35
35
|
|
|
@@ -43,11 +43,11 @@ input.onButtonPressed(Button.A, function() {
|
|
|
43
43
|
})
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
## Step 4
|
|
46
|
+
## {Step 4}
|
|
47
47
|
|
|
48
48
|
Press button **A** in the simulator to try the coin toss code.
|
|
49
49
|
|
|
50
|
-
## Step 5
|
|
50
|
+
## {Step 5}
|
|
51
51
|
|
|
52
52
|
You can animate the coin toss to add the feeling of suspense. Place different ``||basic:show icon||`` blocks before the ``||logic:if||`` to show that the coin is flipping.
|
|
53
53
|
|
|
@@ -65,11 +65,11 @@ input.onButtonPressed(Button.A, function() {
|
|
|
65
65
|
})
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
## Step 6
|
|
68
|
+
## {Step 6}
|
|
69
69
|
|
|
70
70
|
If you have a @boardname@, connect it to USB and click ``|Download|`` to transfer your code.
|
|
71
71
|
|
|
72
|
-
## Step 7
|
|
72
|
+
## {Step 7}
|
|
73
73
|
|
|
74
74
|
Press button **A** for a flip. Test your luck and guess ``heads`` or ``tails`` before the toss is over!
|
|
75
75
|
|
package/docs/projects/compass.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# Compass
|
|
2
2
|
|
|
3
|
-
## Introduction @unplugged
|
|
3
|
+
## {Introduction @unplugged}
|
|
4
4
|
|
|
5
|
-
This tutorial
|
|
5
|
+
This tutorial shows you how to create a program that displays which direction the @boardname@ is pointing. Let's get started!
|
|
6
6
|
|
|
7
7
|

|
|
8
8
|
|
|
9
|
-
## Step 1
|
|
9
|
+
## {Step 1}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
First, store the ``||input:compass heading||`` of the @boardname@ in a variable called ``||variables:degrees||`` in the ``||basic:forever||`` loop.
|
|
12
12
|
|
|
13
13
|
```blocks
|
|
14
14
|
basic.forever(function() {
|
|
@@ -16,7 +16,7 @@ basic.forever(function() {
|
|
|
16
16
|
})
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
## Step 2
|
|
19
|
+
## {Step 2}
|
|
20
20
|
|
|
21
21
|
``||logic:If||`` ``||variables:degrees||`` is ``||logic:less than||`` `45`,
|
|
22
22
|
then the compass heading is mostly pointing toward **North**. ``||basic:Show||`` `N` on the @boardname@.
|
|
@@ -30,7 +30,7 @@ basic.forever(function() {
|
|
|
30
30
|
})
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
## Step 3
|
|
33
|
+
## {Step 3}
|
|
34
34
|
|
|
35
35
|
``||logic:If||`` ``||variables:degrees||`` is less than `135`, the @boardname@ is mostly pointing **East**. ``||basic:Show||`` `E` on the @boardname@.
|
|
36
36
|
|
|
@@ -46,11 +46,11 @@ basic.forever(function() {
|
|
|
46
46
|
})
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
## Step 4
|
|
49
|
+
## {Step 4}
|
|
50
50
|
|
|
51
51
|
Go to the simulator and rotate the @boardname@ logo to simulate changes in the compass heading.
|
|
52
52
|
|
|
53
|
-
## Step 5
|
|
53
|
+
## {Step 5}
|
|
54
54
|
|
|
55
55
|
``||logic:If||`` ``||variables:degrees||`` is less than `225`, the @boardname@ is mostly pointing **South**. ``||basic:Show||`` `S` on the @boardname@.
|
|
56
56
|
|
|
@@ -69,7 +69,7 @@ basic.forever(function() {
|
|
|
69
69
|
})
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
## Step 6
|
|
72
|
+
## {Step 6}
|
|
73
73
|
|
|
74
74
|
``||logic:If||`` ``||variables:degrees||`` is less than `315`, the @boardname@ is mostly pointing **West**. ``||basic:Show||`` `W` on the @boardname@.
|
|
75
75
|
|
|
@@ -89,7 +89,7 @@ basic.forever(function() {
|
|
|
89
89
|
})
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
## Step 7
|
|
92
|
+
## {Step 7}
|
|
93
93
|
|
|
94
94
|
``||logic:If||`` none of these conditions returned true, then the @boardname@ must be pointing **North** again. Display `N` on the @boardname@.
|
|
95
95
|
|
|
@@ -114,13 +114,8 @@ basic.forever(function() {
|
|
|
114
114
|
})
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
-
## Step
|
|
117
|
+
## {Step 9 @unplugged}
|
|
118
118
|
|
|
119
|
-
If you have a @boardname@, click `|Download|` and follow the screen instructions.
|
|
120
|
-
You will have to follow the screen instructions to calibrate your compass.
|
|
119
|
+
If you have a @boardname@, click `|Download|` and follow the screen instructions. You will have to follow the screen instructions to calibrate your compass.
|
|
121
120
|
|
|
122
121
|
https://youtu.be/IL5grHtz_MU
|
|
123
|
-
|
|
124
|
-
```template
|
|
125
|
-
basic.forever(function() {})
|
|
126
|
-
```
|
package/docs/projects/dice.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# Dice
|
|
2
2
|
|
|
3
|
-
## Introduction @unplugged
|
|
3
|
+
## {Introduction @unplugged}
|
|
4
4
|
|
|
5
|
-
Let's turn the @boardname@ into
|
|
5
|
+
Let's turn the @boardname@ into dice!
|
|
6
6
|
(Want to learn how the accelerometer works? [Watch this video](https://youtu.be/byngcwjO51U)).
|
|
7
7
|
|
|
8
8
|

|
|
9
9
|
|
|
10
|
-
## Step 1
|
|
10
|
+
## {Step 1}
|
|
11
11
|
|
|
12
12
|
We need 3 pieces of code: one to detect a throw (shake), another to pick a random number, and then one to show the number.
|
|
13
13
|
|
|
@@ -19,44 +19,51 @@ input.onGesture(Gesture.Shake, function() {
|
|
|
19
19
|
})
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
## Step 2
|
|
22
|
+
## {Step 2}
|
|
23
23
|
|
|
24
24
|
Get a ``||basic:show number||`` block and place it inside the ``||input:on shake||`` block to display a number.
|
|
25
25
|
|
|
26
26
|
```blocks
|
|
27
27
|
input.onGesture(Gesture.Shake, function() {
|
|
28
|
+
//@highlight
|
|
28
29
|
basic.showNumber(0)
|
|
29
30
|
})
|
|
30
31
|
```
|
|
31
32
|
|
|
32
|
-
## Step 3
|
|
33
|
+
## {Step 3}
|
|
33
34
|
|
|
34
35
|
Put a ``||Math:pick random||`` block in the ``||basic:show number||`` block to pick a random number.
|
|
35
36
|
|
|
36
37
|
```blocks
|
|
37
38
|
input.onGesture(Gesture.Shake, function() {
|
|
39
|
+
//@highlight
|
|
38
40
|
basic.showNumber(randint(0, 10))
|
|
39
41
|
})
|
|
40
42
|
```
|
|
41
43
|
|
|
42
|
-
## Step 4
|
|
44
|
+
## {Step 4}
|
|
43
45
|
|
|
44
46
|
A typical dice shows values from `1` to `6`. So, in ``||Math:pick random||``, don't forget to choose the right minimum and maximum values!
|
|
45
47
|
|
|
46
48
|
```blocks
|
|
47
49
|
input.onGesture(Gesture.Shake, function() {
|
|
50
|
+
//@highlight
|
|
48
51
|
basic.showNumber(randint(1, 6))
|
|
49
52
|
})
|
|
50
53
|
```
|
|
51
54
|
|
|
52
|
-
## Step 5
|
|
55
|
+
## {Step 5}
|
|
53
56
|
|
|
54
57
|
Use the simulator to try out your code. Does it show the number you expected?
|
|
55
58
|
|
|
56
|
-
## Step 6
|
|
59
|
+
## {Step 6}
|
|
57
60
|
|
|
58
61
|
If you have a @boardname@ connected, click ``|Download|`` and transfer your code to the @boardname@!
|
|
59
62
|
|
|
63
|
+
```validation.global
|
|
64
|
+
# BlocksExistValidator
|
|
65
|
+
```
|
|
66
|
+
|
|
60
67
|
```template
|
|
61
68
|
input.onGesture(Gesture.Shake, function() {})
|
|
62
69
|
```
|
|
@@ -8,13 +8,13 @@ Learn how to use the LEDs and make a flashing heart!
|
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
11
|
-
## Step 1 @fullscreen
|
|
11
|
+
## {Step 1 @fullscreen}
|
|
12
12
|
|
|
13
13
|
Place the ``||basic:show leds||`` block in the ``||basic:forever||`` block and draw a heart.
|
|
14
14
|
|
|
15
15
|

|
|
16
16
|
|
|
17
|
-
## Step 2
|
|
17
|
+
## {Step 2}
|
|
18
18
|
|
|
19
19
|
Place another ``||basic:show leds||`` block. You can leave it blank and draw what you want.
|
|
20
20
|
|
|
@@ -35,11 +35,11 @@ basic.forever(function() {
|
|
|
35
35
|
})
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
## Step 3
|
|
38
|
+
## {Step 3}
|
|
39
39
|
|
|
40
40
|
Look at the virtual @boardname@, you should see the heart and your drawing blink on the screen.
|
|
41
41
|
|
|
42
|
-
## Step 4
|
|
42
|
+
## {Step 4}
|
|
43
43
|
|
|
44
44
|
If you have a @boardname@ connected, click ``|Download|`` to transfer your code and watch the hearts flash!
|
|
45
45
|
|