Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resets X and Y #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions Lock15
Original file line number Diff line number Diff line change
@@ -0,0 +1,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)
}
})