-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
53 lines (53 loc) · 1.26 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
// Ablauf ist bei jeder Eingabe derselbe: Bildschirm löschen, variable ändern, LED am Bildschirm zeichnen
input.onGesture(Gesture.TiltRight, function () {
// Bildschirm soll nicht gelöscht werden, wenn trauriges Smiley sichtbar ist
if (x >= -1 && x <= 5) {
basic.clearScreen()
}
x += 1
// Wenn Cursor innerhalb des sichtbaren Bereich, dann zeichne LED ansonst trauriges Smiley
if (x >= 0 && x <= 4) {
led.plot(x, y)
} else {
basic.showIcon(IconNames.Sad)
}
})
input.onGesture(Gesture.LogoUp, function () {
if (y >= -1 && y <= 5) {
basic.clearScreen()
}
y += 1
if (y >= 0 && y <= 4) {
led.plot(x, y)
} else {
basic.showIcon(IconNames.Sad)
}
})
input.onGesture(Gesture.TiltLeft, function () {
if (x >= -1 && x <= 5) {
basic.clearScreen()
}
x += -1
if (x >= 0 && x <= 4) {
led.plot(x, y)
} else {
basic.showIcon(IconNames.Sad)
}
})
input.onGesture(Gesture.LogoDown, function () {
if (y >= -1 && y <= 5) {
basic.clearScreen()
}
y += -1
if (y >= 0 && y <= 4) {
led.plot(x, y)
} else {
basic.showIcon(IconNames.Sad)
}
})
// Startpunkt definieren
let y = 0
let x = 0
x = 0
y = 0
led.plot(0, 0)