pxt-calliope/olddocs/js/lessons/screen-wipe/challenges.md

72 lines
1.7 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# screen wipe challenges
Coding challenges for the screen wipe tutorial. #docs
## Before we get started
2016-04-13 17:27:45 +02:00
Complete the [screen wipe](/lessons/screen-wipe) activity and your code will look like this:
2016-03-26 00:47:20 +01:00
```
basic.showAnimation(`
# # # # # # # # # # . . . . . . . . . .
# # # # # # # # # # . . . . . . . . . .
. . . . . # # # # # # # # # # . . . . .
. . . . . # # # # # # # # # # # # # # #
. . . . . . . . . . . . . . . # # # # #
`, 400)
input.onButtonPressed(Button.A, () => {
2016-03-26 00:47:20 +01:00
basic.clearScreen()
})
```
**Challenge 1**
Create an event handler for Button "B".
```
basic.showAnimation(`
# # # # # # # # # # . . . . . . . . . .
# # # # # # # # # # . . . . . . . . . .
. . . . . # # # # # # # # # # . . . . .
. . . . . # # # # # # # # # # # # # # #
. . . . . . . . . . . . . . . # # # # #
`, 400)
input.onButtonPressed(Button.A, () => {
2016-03-26 00:47:20 +01:00
basic.clearScreen()
})
input.onButtonPressed(Button.B, () => {
2016-03-26 00:47:20 +01:00
})
```
**Challenge 2**
Replay the animation when the "B" button is pressed by typing in `basic->show animation(..., 400)`.
```
basic.showAnimation(`
# # # # # # # # # # . . . . . . . . . .
# # # # # # # # # # . . . . . . . . . .
. . . . . # # # # # # # # # # . . . . .
. . . . . # # # # # # # # # # # # # # #
. . . . . . . . . . . . . . . # # # # #
`, 400)
input.onButtonPressed(Button.A, () => {
2016-03-26 00:47:20 +01:00
basic.clearScreen()
})
input.onButtonPressed(Button.B, () => {
2016-03-26 00:47:20 +01:00
basic.showAnimation(`
# # # # # # # # # # . . . . . . . . . .
# # # # # # # # # # . . . . . . . . . .
. . . . . # # # # # # # # # # . . . . .
. . . . . # # # # # # # # # # # # # # #
. . . . . . . . . . . . . . . # # # # #
`, 400) // ***
})
```
**Challenge 3**
Show an animation that scrolls back up when you press button "B".
* tap the `run` button to view your final product!