Microbit 弹砖块

let game2 = 0
let step = 0
let y = 0
let x = 0
basic.showIcon(IconNames.Heart)
basic.pause(2000)
x = 0
y = 2
basic.showLeds(`
    . . . . .
    . . . . .
    . . . . .
    . . . . .
    . . . . .
    `)
for (let i = 0; i < 3; i++) {
    led.toggle(2, x)
    if (x < 3) {
        led.unplot(2, x - 1)
    }
    if (x < 2) {
        x += 1
    }
    basic.pause(500)
}
step = -1
game2 = 0
while (game2 == 0) {
    led.unplot(y, x)
    y += step
    led.toggle(y, x)
    basic.pause(1000)
    if (y == 0) {
        if (input.buttonIsPressed(Button.A)) {
            step = 1
        } else {
            game2 = 1
            basic.showLeds(`
                . . # . .
                . . . # .
                # # # # #
                . . . # .
                . . # . .
                `)
        }
    } else if (y == 4) {
        if (input.buttonIsPressed(Button.A)) {
            step = -1
        } else {
            game2 = 1
            basic.showLeds(`
                . . # . .
                . # . . .
                # # # # #
                . # . . .
                . . # . .
                `)
        }
    }
}
basic.pause(2000)
basic.showIcon(IconNames.Sad)