Hi folks, quite new to Construct(3), but not a new developer.
I'm trying to figure out a good way to handle keys and doors in Construct. Here's a scenario.
I have 5 keys and 5 doors. Each key opens the relative # door. Eg: Key 1 opens Door 1, Key 2-Door 2 etc.
If I walk over a key (eg:1) I pick it up. If I'm holding a key the original key gets replaced on the screen in the original spot.
Heres a quick 'action list'.
Player hits key 1, picks it up (Key 1 disappears from screen). Player is holding key 1.
Player hits key 3, Key 1 shows back in its spot. key 3 disappears from the screen and player is holding key 3.
Player hits key 4, Key 3 shows back in its spot. key 4 disappears from the screen and player is holding key 4.
Player opens door 4. Key (and door) 4 are now destroyed, player is holding NO key. Key 4 will not be displayed again.
-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----
Since the graphic of each key/door are different, they aren't instances. (I decided that wasn't prudent since the keys are numbered) they are all separate objects. Door1, Door2, Key1, Key2. This can be changed if needed.
In pseudo code, I think its something like this...
If Player collides with Key
If Key(KeyHeld Variable).destroyed = False. -- Only show the held key if it wasn't destroyed
Key(KeyHeld Variable).Visible = true. -- Re-Show the old key back in it's spot.
End
KeyHeld.Variable = Key.KeyNumber. -- Update key held to the key we just hit.
Key(KeyHeld Variable).Visible = false. -- Hide the key onscreen that we hit.
end
If Player collides with a door
If DoorNumber = KeyHeld Variable. -- If the key matches the door
Destroy DoorNumber -- Remove the door
Destroy Key(KeyHeld Variable) -- Destroy the key object based on the variable held
KeyHeld Variable = 0 -- Reset the variable since we're not actually holding a key
end
end
__________________________________________________________________
Based on the pseudo code, I'm not sure how in construct to nest the checks of keys 1-5 (I actually have 8).
I also believe I can't use Key(KeyHeld Variable) either. I couldn't figure out how to easily link a variable to an object even after several forum/google sessions.
I hope there is enough and not too much info on the post, I'd appreciate any input for this construct NooB!
Thank you.