-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
67 lines (54 loc) · 1.31 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//let level1 = [0, 0, 1, 1, 0, -1, -1, 0, 0, 1, 1, 0, -1, -1, 0, 0, 1, 1, 0, -1, -1, 0, 0, 1, 1, 0, -1, -1]
let level1 = [0, 0, 1, 1, 0]
let xProgression = 0
let yOffset = 0
let deltaYRunner = 0
let lastDirection = 0
led.setDisplayMode(DisplayMode.BlackAndWhite)
basic.clearScreen()
basic.forever(function () {
// nach hinten gekippt
if (input.rotation(Rotation.Pitch) < 0) {
yOffset--
if (lastDirection === -1) {
deltaYRunner -= 2
} else {
deltaYRunner -= 1
}
lastDirection = -1
} else {
yOffset++
if (lastDirection === 1) {
deltaYRunner += 2
} else {
deltaYRunner += 1
}
lastDirection = +1
}
paint()
pause(1000);
xProgression++;
level1.push(randint(-1, 1))
})
function paint()
{
basic.clearScreen()
paintCave();
paintRunner();
}
function paintCave()
{
let brightness = 100
for (let x = 0; x < 5; x++) {
let yCave = level1.get(xProgression + x)
if (typeof yCave === 'number') {
led.plotBrightness(x, 1 + yCave + yOffset, brightness)
led.plotBrightness(x, 5 + yCave + yOffset, brightness)
}
}
}
function paintRunner()
{
let brightness = 210
led.plotBrightness(0, 3 + deltaYRunner, brightness)
}