keys = [ key0, key1, key2 ]
locks = [ [lockA, lockB, lockC], [lockD, lockE], [lockF, lockG, lockH, lockI] ]
where key0 opens locks[0], i.e. locks A, B, and C. I should be able to assign the key to the lock(s), rather than just having it automatically determined by the order in which they are added to the arrays (i.e. the order in which they are encountered on the map). But I (optimistically) predict that once I've got locks squared away, I'll be able to actually start designing levels! Yaaaay!
Oh, and note to self: maybe I want an indicator on the side telling me what direction my gravity is going?
So, what we talked about yesterday, assigning capital letters to locks and lower case letters to keys in your map format should work well. If you only want one-to-one correspondence from locks to keys, you can just make key "a" open lock "A", etc. If you want multiple keys per lock, or multiple locks per key, you can store a mapping from locks to arrays of keys or keys to arrays of locks using JSON (which can transform javascript values to strings and vice versa easily, using JSON.stringify() and JSON.parse() ). In that case, you'll need figure out some way of indicating to the player what the mapping is (in the case of one-to-one, it's trivial, just color the lock and key the same).
ReplyDeleteOne-to-one is a bit simpler to implement and you can achieve a multiple key per lock effect by putting locks next to each other. Come to think of it, with the one-to-one scheme you can also achieve multiple keys per lock by having multiple "a"s, and requiring there to be none left on the board to unlock "A".
This comment has been removed by the author.
ReplyDelete