Merge branch 'master' of https://github.com/Microsoft/pxt-microbit
This commit is contained in:
commit
eea179e07c
@ -234,22 +234,19 @@ Here are the blocks to make your coin flipper. When you press button
|
||||
on the LED screen.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
if (Math.randomBoolean()) {
|
||||
basic.showString("H");
|
||||
} else {
|
||||
basic.showString("T");
|
||||
}
|
||||
});
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
if (Math.randomBoolean()) {
|
||||
basic.showString("H");
|
||||
} else {
|
||||
basic.showString("T");
|
||||
}
|
||||
});
|
||||
```
|
||||
### ~hint
|
||||
|
||||
The ``pick random true or false`` block randomly tells the ``if``
|
||||
block `true` or `false`. If the ``pick`` block
|
||||
picked `true`, the ``if`` block shows the letter `H`. Otherwise, it
|
||||
shows the letter `T`.
|
||||
block `true` or `false`. If the ``pick`` block picked `true`, the
|
||||
``if`` block shows the letter `H`. Otherwise, it shows the letter `T`.
|
||||
|
||||
That's it!
|
||||
|
||||
@ -280,20 +277,18 @@ show your score.
|
||||
When you're done, your coin flipping program should look like this:
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
if (Math.randomBoolean()) {
|
||||
basic.showString("H");
|
||||
} else {
|
||||
basic.showString("T");
|
||||
}
|
||||
});
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
game.addScore(1);
|
||||
});
|
||||
input.onButtonPressed(Button.AB, () => {
|
||||
basic.showNumber(game.score());
|
||||
});
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
if (Math.randomBoolean()) {
|
||||
basic.showString("H");
|
||||
} else {
|
||||
basic.showString("T");
|
||||
}
|
||||
});
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
game.addScore(1);
|
||||
});
|
||||
input.onButtonPressed(Button.AB, () => {
|
||||
basic.showNumber(game.score());
|
||||
});
|
||||
```
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
# Change Tempo By
|
||||
|
||||
Change the tempo by the specified amount
|
||||
Makes the [tempo](/reference/music/tempo) (speed of a piece of music)
|
||||
faster or slower by the amount you say.
|
||||
|
||||
## Simulator
|
||||
|
||||
Simulation of this function is available in many, but not all browsers.
|
||||
This function only works on the micro:bit and in some browsers.
|
||||
|
||||
```sig
|
||||
music.changeTempoBy(20)
|
||||
@ -12,7 +13,21 @@ music.changeTempoBy(20)
|
||||
|
||||
### Parameters
|
||||
|
||||
* `bpm` : [Number](/reference/types/number) - change the tempo by beats per minute
|
||||
* a [number](/reference/types/number) that says how much to change the bpm (beats per minute, or number of beats in a minute of the music that the micro:bit is playing).
|
||||
|
||||
### Examples
|
||||
|
||||
This program makes the music faster by 12 bpm.
|
||||
|
||||
```blocks
|
||||
music.changeTempoBy(12)
|
||||
```
|
||||
|
||||
This program makes the music _slower_ by 12 bpm.
|
||||
|
||||
```blocks
|
||||
music.changeTempoBy(-12)
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
|
@ -1,14 +1,17 @@
|
||||
# Set Tempo
|
||||
|
||||
Sets the tempo to the specified amount
|
||||
Makes the tempo (speed of a piece of music) as fast or slow as you say.
|
||||
|
||||
```sig
|
||||
music.setTempo(60)
|
||||
```
|
||||
## Simulator
|
||||
|
||||
This function only works on the micro:bit and in some browsers.
|
||||
|
||||
### Parameters
|
||||
|
||||
* Returns : [Number](/reference/types/number) - sets the tempo in beats per minute
|
||||
* a [number](/reference/types/number) that means the bpm you want (beats per minute, or number of beats in a minute of the music that the micro:bit is playing).
|
||||
|
||||
### See also
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user