pxt-calliope/olddocs/js/lessons/on-fall/challenges.md

70 lines
1.3 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# landslide challenges
2016-04-02 01:22:47 +02:00
The on fall function.
2016-03-26 00:47:20 +01:00
### Challenge 0
2016-11-02 01:44:37 +01:00
Welcome! This [guided tutorial](https://live.microbit.co.uk/td/lessons/on-fall/tutorial) will show you how to detect when the @boardname@ is falling. Your goal is to write a program that detects when the @boardname@ falls!
2016-03-26 00:47:20 +01:00
```
input.onFall(() => {
images.createImage(`
. . # . .
. . # . .
. . # . .
. . . . .
. . # . .
`).showImage(0) // ***
})
```
### Challenge 1
Add a pause within `input->on fall`. This will allow us to display another image in the next challenge.
```
input.onFall(() => {
images.createImage(`
. . # . .
. . # . .
. . # . .
. . . . .
. . # . .
`).showImage(0)
basic.pause(2000) // ***
})
```
### Challenge 2
Create and display an `X` after the pause from Challenge 1
```
input.onFall(() => {
images.createImage(`
. . # . .
. . # . .
. . # . .
. . . . .
. . # . .
`).showImage(0)
basic.pause(2000)
images.createImage(`
# . . . #
. # . # .
. . # . .
. # . # .
# . . . #
`).showImage(0) // ***
})
```
### Challenge 3
2016-11-02 01:44:37 +01:00
Create a loop so that the @boardname@ alternates between the exclamation point and "X" images when the @boardname@ falls. You will need a `forever` loop and a pause at the end of the loop to do this.
2016-03-26 00:47:20 +01:00
## See Also
2016-04-13 17:27:45 +02:00
[on shake](/reference/input/on-gesture)
2016-03-26 00:47:20 +01:00