2016-03-26 00:47:20 +01:00
|
|
|
# screen wipe blocks challenges
|
|
|
|
|
|
|
|
Coding challenges for screen wipe.
|
|
|
|
|
|
|
|
## Before we get started
|
|
|
|
|
2016-05-11 23:52:25 +02:00
|
|
|
Complete the [screen wipe](/lessons/screen-wipe/activity) activity and your code will look like this:
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
```blocks
|
|
|
|
basic.showLeds(`
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
`)
|
|
|
|
basic.showLeds(`
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
. . . . .
|
|
|
|
`)
|
|
|
|
basic.showLeds(`
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
. . . . .
|
|
|
|
`)
|
|
|
|
basic.showLeds(`
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
`)
|
|
|
|
input.onButtonPressed(Button.A, () => {
|
|
|
|
basic.clearScreen()
|
|
|
|
})
|
|
|
|
|
|
|
|
```
|
|
|
|
|
2017-09-07 22:42:08 +02:00
|
|
|
## Challenge 1
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
Create an event handler for Button B.
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
basic.showLeds(`
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
`)
|
|
|
|
basic.showLeds(`
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
. . . . .
|
|
|
|
`)
|
|
|
|
basic.showLeds(`
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
. . . . .
|
|
|
|
`)
|
|
|
|
basic.showLeds(`
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
`)
|
|
|
|
input.onButtonPressed(Button.A, () => {
|
|
|
|
basic.clearScreen()
|
|
|
|
})
|
|
|
|
input.onButtonPressed(Button.B, () => {
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
```
|
|
|
|
|
2017-09-07 22:42:08 +02:00
|
|
|
## Challenge 2
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2016-05-27 00:24:10 +02:00
|
|
|
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
Replay the animation when the "B" button is pressed placing the `show LEDs` block on the canvas.
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
basic.showLeds(`
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
`)
|
|
|
|
basic.showLeds(`
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
. . . . .
|
|
|
|
`)
|
|
|
|
basic.showLeds(`
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
. . . . .
|
|
|
|
`)
|
|
|
|
basic.showLeds(`
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
`)
|
|
|
|
input.onButtonPressed(Button.A, () => {
|
|
|
|
basic.clearScreen()
|
|
|
|
})
|
|
|
|
input.onButtonPressed(Button.B, () => {
|
|
|
|
basic.showLeds(`
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
`)
|
|
|
|
basic.showLeds(`
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
. . . . .
|
|
|
|
`)
|
|
|
|
basic.showLeds(`
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
. . . . .
|
|
|
|
`)
|
|
|
|
basic.showLeds(`
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
`)
|
|
|
|
})
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2017-09-07 22:42:08 +02:00
|
|
|
## Challenge 3
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
Show an animation that scrolls back up when you press button "B".
|
|
|
|
|
|
|
|
* tap the *run* button to view your final product!
|