-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
40 lines (40 loc) · 1.25 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
input.onButtonEvent(Button.A, input.buttonEventClick(), function () {
sprite.change(LedSpriteProperty.X, -1)
})
input.onButtonEvent(Button.B, input.buttonEventClick(), function () {
sprite.change(LedSpriteProperty.X, 1)
})
let punkte = 0
let catchme: game.LedSprite = null
let sprite: game.LedSprite = null
sprite = game.createSprite(2, 4)
let leben = 3
basic.showIcon(IconNames.Heart)
basic.showNumber(leben)
basic.forever(function () {
catchme = game.createSprite(randint(0, 4), 0)
for (let index = 0; index < 4; index++) {
basic.pause(500)
catchme.change(LedSpriteProperty.Y, 1)
}
if (sprite.get(LedSpriteProperty.X) == catchme.get(LedSpriteProperty.X)) {
punkte += 1
music.playTone(440, music.beat(BeatFraction.Sixteenth))
} else {
leben += -1
music.playTone(247, music.beat(BeatFraction.Whole))
if (leben > 0) {
basic.clearScreen()
basic.showIcon(IconNames.Heart)
basic.showNumber(leben)
basic.pause(500)
} else {
while (true) {
basic.showIcon(IconNames.Skull, 800)
basic.showString("SCORE:", 100)
basic.showNumber(punkte)
}
}
}
catchme.delete()
})