-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathLock15
More file actions
92 lines (92 loc) · 1.86 KB
/
Lock15
File metadata and controls
92 lines (92 loc) · 1.86 KB
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
83
84
85
86
87
88
89
90
91
92
let Unlocked_Screen: Image = null
let Locked_Screen: Image = null
let allowedToOpen = false
let Correct = false
let Waiting = false
let Locked = false
let Continue = false
let Y = 0
let X = 0
input.onButtonPressed(Button.B, function () {
Y = 0
X = X + 2
if (X == 6) {
X = 0
}
led.plot(X, Y)
})
function PasswordEntry() {
if (led.point(0, 3) && led.point(2, 1)) {
Continue = true
} else if (led.point(0, 2) && (led.point(2, 0) && led.point(4, 4))) {
Locked = false
Correct = true
} else {
Continue = true
}
}
input.onButtonPressed(Button.AB, function () {
if (Continue) {
Continue = false
X = 0
Y = 0
basic.clearScreen()
basic.pause(500)
} else if (Waiting) {
Waiting = false
basic.clearScreen()
} else if (Waiting == false) {
PasswordEntry()
}
})
input.onPinReleased(TouchPin.P0, function () {
if (allowedToOpen == false) {
basic.showString("FAILED")
basic.showLeds(`
# . . . #
. # . # .
. . # . .
. # . # .
# . . . #
`)
control.waitMicros(5000)
}
})
input.onButtonPressed(Button.A, function () {
led.plot(X, Y)
Y = Y + 1
if (Y == 5) {
Y = 0
}
})
X = 0
Y = 0
Correct = false
Waiting = true
Locked = true
Continue = false
Unlocked_Screen = images.createImage(`
. . # . .
. # . # .
. # . . .
. # # # .
. # # # .
`)
Locked_Screen = images.createImage(`
. . # . .
. # . # .
. # # # .
. # # # .
. # # # .
`)
allowedToOpen = false
basic.forever(function () {
if (Waiting) {
Locked_Screen.showImage(0)
} else if (Correct) {
Unlocked_Screen.showImage(0)
allowedToOpen = true
} else if (Continue) {
Locked_Screen.showImage(0)
}
})