Deleted loop around event handlers in coin flipper
This commit is contained in:
parent
bd835a8a6e
commit
6de2f22542
@ -234,22 +234,19 @@ Here are the blocks to make your coin flipper. When you press button
|
|||||||
on the LED screen.
|
on the LED screen.
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
basic.forever(() => {
|
input.onButtonPressed(Button.B, () => {
|
||||||
input.onButtonPressed(Button.B, () => {
|
if (Math.randomBoolean()) {
|
||||||
if (Math.randomBoolean()) {
|
basic.showString("H");
|
||||||
basic.showString("H");
|
} else {
|
||||||
} else {
|
basic.showString("T");
|
||||||
basic.showString("T");
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
### ~hint
|
### ~hint
|
||||||
|
|
||||||
The ``pick random true or false`` block randomly tells the ``if``
|
The ``pick random true or false`` block randomly tells the ``if``
|
||||||
block `true` or `false`. If the ``pick`` block
|
block `true` or `false`. If the ``pick`` block picked `true`, the
|
||||||
picked `true`, the ``if`` block shows the letter `H`. Otherwise, it
|
``if`` block shows the letter `H`. Otherwise, it shows the letter `T`.
|
||||||
shows the letter `T`.
|
|
||||||
|
|
||||||
That's it!
|
That's it!
|
||||||
|
|
||||||
@ -280,20 +277,18 @@ show your score.
|
|||||||
When you're done, your coin flipping program should look like this:
|
When you're done, your coin flipping program should look like this:
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
basic.forever(() => {
|
input.onButtonPressed(Button.B, () => {
|
||||||
input.onButtonPressed(Button.B, () => {
|
if (Math.randomBoolean()) {
|
||||||
if (Math.randomBoolean()) {
|
basic.showString("H");
|
||||||
basic.showString("H");
|
} else {
|
||||||
} else {
|
basic.showString("T");
|
||||||
basic.showString("T");
|
}
|
||||||
}
|
});
|
||||||
});
|
input.onButtonPressed(Button.A, () => {
|
||||||
input.onButtonPressed(Button.A, () => {
|
game.addScore(1);
|
||||||
game.addScore(1);
|
});
|
||||||
});
|
input.onButtonPressed(Button.AB, () => {
|
||||||
input.onButtonPressed(Button.AB, () => {
|
basic.showNumber(game.score());
|
||||||
basic.showNumber(game.score());
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user