pxt-calliope/docs/lessons/game-of-chance/challenges.md

49 lines
1.2 KiB
Markdown
Raw Permalink Normal View History

2016-03-26 00:47:20 +01:00
# game of chance challenges
Coding challenges for the answering machine tutorial.
## Before we get started
2016-04-13 17:27:45 +02:00
Complete the [game of chance](/lessons/game-of-chance/activity) activity and your code will look like this:
2016-03-26 00:47:20 +01:00
```blocks
basic.showString("SELECT A BUTTON")
```
### Challenge 1
Now we need to to play the game of chance by responding to the message. We want to respond `YOU WIN` when button `A` is pressed. Add a condition for button `A` and inside it show the string `YOU WIN`.
```blocks
basic.showString("SELECT A BUTTON")
input.onButtonPressed(Button.A, () => {
basic.showString("YOU WIN")
})
```
* `Run` the code to see if it works as expected.
### Challenge 2
2016-11-02 01:44:37 +01:00
What if @boardname@'s answer to the question is GAME OVER? Let's have `GAME OVER` be displayed when button `B` is pressed. Add a condition for button `B` and inside it show the `GAME OVER`.
2016-03-26 00:47:20 +01:00
```blocks
basic.showString("SELECT A BUTTON")
input.onButtonPressed(Button.A, () => {
basic.showString("YOU WIN")
})
input.onButtonPressed(Button.B, () => {
game.gameOver()
})
```
* `Run` the code to see if it works as expected.
2016-05-06 18:28:26 +02:00
### Challenge 3
2016-03-26 00:47:20 +01:00
When you are asked a yes or no question, do you always say yes or no? Add a condition for `on shake` that displays `TRY AGAIN`.