-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
59 lines (59 loc) · 1.44 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
input.onButtonPressed(Button.A, function () {
basic.showArrow(ArrowNames.South)
oldTerningkast = terningkast
terningkast = randint(0, 9)
basic.pause(100)
if (terningkast <= oldTerningkast) {
poeng += 1
basic.showIcon(IconNames.Yes)
music.playMelody("C5 - C5 - - - - - ", 340)
basic.pause(100)
} else {
highScore = poeng
poeng = 0
shake = -1
music.playMelody("B - B - G E D C5 ", 340)
basic.pause(2000)
}
})
input.onButtonPressed(Button.B, function () {
basic.showArrow(ArrowNames.North)
oldTerningkast = terningkast
terningkast = randint(0, 9)
basic.pause(100)
if (terningkast >= oldTerningkast) {
poeng += 1
basic.showIcon(IconNames.Yes)
music.playMelody("C5 - C5 - - - - - ", 340)
basic.pause(100)
} else {
highScore = poeng
poeng = 0
shake = -1
music.playMelody("B - B - G E D C5 ", 340)
basic.pause(2000)
}
})
input.onGesture(Gesture.Shake, function () {
terningkast = randint(0, 9)
shake = 1
})
let highScore = 0
let poeng = 0
let shake = 0
let terningkast = 0
let oldTerningkast = 0
oldTerningkast = 0
terningkast = 0
shake = 0
poeng = 0
basic.showIcon(IconNames.Happy)
basic.forever(function () {
if (shake == 1) {
basic.showNumber(terningkast)
}
if (shake == -1) {
basic.showString("HS: ")
basic.showNumber(highScore)
}
})