View difference between Paste ID: nwGx937E and sjeFqRbZ
SHOW: | | - or go back to the newest paste.
1
let ey = 0
2
let ex = 0
3
let yy = 0
4
let xx = 0
5
xx = 2
6
yy = 2
7
led.plot(2, 2)
8
ex = Math.randomRange(0, 4)
9
ey = Math.randomRange(0, 4)
10
basic.forever(function () {
11
    if (input.acceleration(Dimension.X) < -50) {
12
        if (xx > 0) {
13
            led.unplot(xx, yy)
14
            xx += -1
15
            basic.pause(100)
16
        }
17
    }
18
    if (input.acceleration(Dimension.X) > 50) {
19
        if (xx < 4) {
20
            led.unplot(xx, yy)
21
            xx += 1
22
            basic.pause(100)
23
        }
24
    }
25
    if (input.acceleration(Dimension.Y) > 50) {
26
        if (yy < 4) {
27
            led.unplot(xx, yy)
28
            yy += 1
29
            basic.pause(100)
30
        }
31
    }
32
    if (input.acceleration(Dimension.Y) < -50) {
33
        if (yy > 0) {
34
            led.unplot(xx, yy)
35
            yy += -1
36
            basic.pause(100)
37
        }
38
    }
39
    if (ex == xx && ey == yy) {
40
        led.unplot(ex, ey)
41
        ex = Math.randomRange(0, 4)
42
        ey = Math.randomRange(0, 4)
43
    }
44
    led.plot(xx, yy)
45
    basic.pause(100)
46
    led.unplot(xx, yy)
47
    basic.pause(100)
48
    led.plot(ex, ey)
49
    basic.pause(100)
50
})