pxt-calliope/docs/lessons/screen-wipe/challenges.md
Sam El-Husseini e3975e65e5 pxt-microbit Accessibility PR (#529)
* Accessibility changes
2017-09-07 13:42:08 -07:00

2.3 KiB

screen wipe blocks challenges

Coding challenges for screen wipe.

Before we get started

Complete the screen wipe activity and your code will look like this:

basic.showLeds(`
    # # # # #
    # # # # #
    . . . . .
    . . . . .
    . . . . .
    `)
basic.showLeds(`
    # # # # #
    # # # # #
    # # # # #
    # # # # #
    . . . . .
    `)
basic.showLeds(`
    . . . . .
    . . . . .
    # # # # #
    # # # # #
    . . . . .
    `)
basic.showLeds(`
    . . . . .
    . . . . .
    . . . . .
    # # # # #
    # # # # #
    `)
input.onButtonPressed(Button.A, () => {
    basic.clearScreen()
})

Challenge 1

Create an event handler for Button B.

basic.showLeds(`
    # # # # #
    # # # # #
    . . . . .
    . . . . .
    . . . . .
    `)
basic.showLeds(`
    # # # # #
    # # # # #
    # # # # #
    # # # # #
    . . . . .
    `)
basic.showLeds(`
    . . . . .
    . . . . .
    # # # # #
    # # # # #
    . . . . .
    `)
basic.showLeds(`
    . . . . .
    . . . . .
    . . . . .
    # # # # #
    # # # # #
    `)
input.onButtonPressed(Button.A, () => {
    basic.clearScreen()
})
input.onButtonPressed(Button.B, () => {

})

Challenge 2

Replay the animation when the "B" button is pressed placing the show LEDs block on the canvas.

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(`
    . . . . .
    . . . . .
    . . . . .
    # # # # #
    # # # # #
    `)
})

Challenge 3

Show an animation that scrolls back up when you press button "B".

  • tap the run button to view your final product!