ok here's some code....
create 3 global variables for the locks..integrers
in this case
Lock1
Lock2
Lock3
create a large hotspot to hold the main lock image..
create 3 hotspots- one on each of the lock "teeth"
set them to reverse their variable on each click..tooth one reverses Lock1 etc..swopping the main hotspot image to one with that tooth up rather than down..(see images in previous post)
create a seperate hotspot to allow the user to "check" the lock to see if it is opened and add this code to that "check lock" hotspot..
- Code: Select all
If Lock1 = 1 And Lock2 = 1 And Lock3 = 1 Then
Text(2).Caption = " no..that's not right "
randomize
i = int( RND * 6 ) + 1
If i = 1 then Lock1 = 0
If i = 2 then Lock2 = 0
If i = 3 then Lock3 = 0
If i = 4 then Lock1 = 1
If i = 5 then Lock2 = 1
If i = 6 then Lock3 = 1
ElseIf Lock1 = 0 And Lock2 = 1 And lock3 = 1 Then
Text(2).Caption = " no..that's not right "
randomize
i = int( RND * 6 ) + 1
If i = 1 then Lock1 = 0
If i = 2 then Lock2 = 0
If i = 3 then Lock3 = 0
If i = 4 then Lock1 = 1
If i = 5 then Lock2 = 1
If i = 6 then Lock3 = 1
ElseIf Lock1 = 0 And Lock2 = 0 And Lock3 = 1 Then
Text(2).Caption = " Yes that's got it... "
Else
Text(2).Caption = "test the pick.. "
randomize
i = int( RND * 6 ) + 1
If i = 1 then Lock1 = 0
If i = 2 then Lock2 = 0
If i = 3 then Lock3 = 0
If i = 4 then Lock1 = 1
If i = 5 then Lock2 = 1
If i = 6 then Lock3 = 1
End If
bit fiendish in a way..because if the player doesn't get it right first time it automatically scrambles the code in effect...or at least from the players point of view it does..even if the soloution remains the same..
can be dead easy or it can be quite a long job to crack the lock..which might be a good thing i dunno...can't stand writing code so there it is....lol
wanted to add a timer to the whole thing but couldn't get that to work...(expected end of statement error etc etc...yawn..no patience for that sort of fiddling about at all...dot in wrong place...etc etc)
of course the more "teeth" the lock has the more difficult it becomes...3 is the bare minimum really to make it playable...but the code gets bigger and bigger each time for a newbie like myself to cope with
i just want something to add spice to opening doors cupboards cases etc without going the full way and turning it into a major puzzle
this is probably better and harder to crack..
- Code: Select all
If Lock1 = 1 And Lock2 = 0 And Lock3 = 1 Then
Text(2).Caption = " yes that's got it.."
ElseIf Lock1 = 0 And Lock2 = 0 And Lock3 = 0 Then
Text(2).Caption = " no..i'll try again.."
randomize
i = int( RND * 3 ) + 1
If i = 1 then Lock1 = 0
If i = 2 then Lock2 = 1
If i = 3 then Lock3 = 0
Else
Text(2).Caption = "test the pick.. "
randomize
i = int( RND * 6 ) + 1
If i = 1 then Lock1 = 0
If i = 2 then Lock2 = 1
If i = 3 then Lock3 = 0
End If
in that if the player gets it wrong the lock resets one of the teeth to the wrong setting...or possibly even tougher but more logical
- Code: Select all
If Lock1 = 1 And Lock2 = 0 And Lock3 = 1 Then
Text(2).Caption = " yes that's got it.."
ElseIf Lock1 = 0 And Lock2 = 0 And Lock3 = 0 Then
Text(2).Caption = " no..i'll try again.."
Lock1 = 0
Lock2 = 1
Lock3 = 0
Else
Text(2).Caption = "test the pick.. "
Lock1 = 0
Lock2 = 1
Lock3 = 0
End If
i dunno...this way the whole lock is reset to the inncorrect settings after each wrong attempt....with some sort of provisional clue (??) this might be a mid level puzzle for some minor door or desk drawer..if you are told the soloution is "this way/that way/this way" you might be able to suss out that the best way to crack the lock...shag only knows....
with the soloution being
1 0 1
if you are given a clue to the on off on nature of the answer..
and you know the lock resets to an entirely wrong setting ie
0 1 0
then you can crack the lock in a vaguely logical fashion...and it's also do-able by sheer trail and error if all else fails...so it won't dead end you..seems ok