pxt-calliope/olddocs/js/lessons/screen-up-and-down/challenges.md

65 lines
1.1 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# screen up and down challenges
2016-04-02 01:22:47 +02:00
The on screen up function.
2016-03-26 00:47:20 +01:00
**Challenge 0**
2016-04-13 17:27:45 +02:00
Congratulations! You have completed the [Screen Up/Down tutorial](/hqjwkb) . You should have an image of a heart created and shown when the screen is moved up.
2016-03-26 00:47:20 +01:00
```
input.onScreenUp(() => {
images.createImage(`
# # . # #
# # # # #
# # # # #
. # # # .
. . # . .
`).showImage(0)
})
```
**Challenge 1**
2016-11-02 01:44:37 +01:00
Now have the @boardname@ do something when the screen is moved downward. You can do this by calling the on screen down method. Do not do anything when you call the on screen down method.
2016-03-26 00:47:20 +01:00
```
input.onScreenUp(() => {
images.createImage(`
# # . # #
# # # # #
# # # # #
. # # # .
. . # . .
`).showImage(0)
})
input.onScreenDown(() => {
})
```
**Challenge 2**
2016-11-02 01:44:37 +01:00
When the @boardname@ is moved downward, create and show an image of an upside down heart.
2016-03-26 00:47:20 +01:00
```
input.onScreenUp(() => {
images.createImage(`
# # . # #
# # # # #
# # # # #
. # # # .
. . # . .
`).showImage(0)
})
input.onScreenDown(() => {
images.createImage(`
. . # . .
. # # # .
# # # # #
# # # # #
# # . # #
`).showImage(0) // ***
})
```