pxt-calliope/docs/lessons/catch-the-egg-game/tutorial.md
Sam El-Husseini e3975e65e5 pxt-microbit Accessibility PR (#529)
* Accessibility changes
2017-09-07 13:42:08 -07:00

774 B

catch the egg game tutorial

Rebuild the game!

The blocks have been shuffled! Put them back together so that...

  • an egg LED falls from the top of the screen, row by row.
  • a basket LED is on the bottom row and can be moved by using the accelerometer X data.
  • if the egg LED reaches the last row, reset the egg position to the first row.
let basketX = 2
let eggX = 2
let eggY = 0
basic.forever(() => {
    led.unplot(basketX, 4)
    led.unplot(eggX, eggY)
    eggY = eggY + 1
    led.plot(eggX, eggY)
    basic.pause(300)
    let accX = input.acceleration(Dimension.X)
    basketX = 2 + Math.min(2, Math.max(-2, accX / 200))
    led.plot(basketX, 4)
    if (eggY > 4) {
        eggY = -1
        eggX = Math.random(5)
    }
    basic.pause(300)
})