-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
82 lines (72 loc) · 2.02 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
let i = 0
let bclicked = 0
let atimes = 0
function interact(interval: number) {
basic.clearScreen()
i = 1
while (i < interval + 1) {
basic.showString("" + ("" + recta(i)))
basic.pause(100)
basic.clearScreen()
i += 1
}
}
function recta(n: number) {
if (n < 0) {
basic.showString("Si us plau selecciona un valor")
}
let result = 3 * n ** 2 + n + 1
return result
}
function numElements() {
while (bclicked < 1) {
if (input.buttonIsPressed(Button.A)) {
basic.showString("A")
basic.clearScreen()
atimes += 1
basic.showString("" + ("" + atimes))
} else if (input.buttonIsPressed(Button.B)) {
basic.showString("B")
bclicked += 1
}
basic.pause(50)
}
basic.clearScreen()
basic.showString("Calculant Recta :)")
interact(atimes)
}
function showIcon() {
basic.clearScreen()
music.startMelody(music.builtInMelody(Melodies.JumpUp), MelodyOptions.Once)
for (let index = 0; index < 4; index++) {
basic.showLeds(`
. # . # .
. . . . .
# . . . #
. # # # .
. . . . .
`)
music.startMelody(music.builtInMelody(Melodies.JumpUp), MelodyOptions.Once)
}
basic.showString("Hola")
music.startMelody(music.builtInMelody(Melodies.Ode), MelodyOptions.Once)
basic.clearScreen()
basic.showString("Amb aquest Programa pots calcular la recta")
basic.clearScreen()
}
basic.forever(function on_forever() {
music.setBuiltInSpeakerEnabled(true)
atimes = 0
bclicked = 0
showIcon()
basic.showString("Selecciona els valors")
basic.showLeds(`
. # . # .
. . . . .
# . . . #
. # # # .
. . . . .
`)
numElements()
basic.pause(500)
})