Passcoded Doors

This forum is currently in read-only mode.
0 favourites
From the Asset Store
The package contains 105 sounds This sound library is perfect for voicing mechanical doors in your Sci-Fi game.
  • Ok if you've played Impossible Mission (I haven't) or Zillion for the Sega Master System you will know EXACTLY what im talking about. For those who don't know what im talking about this is what I'm thinking. Your player enters a room with a computer, a locked door, and 4 containers. Inside each container is a part of the password to enter into the computer which unlocks the door. Now that shouldn't be too hard but what if you want to do that for each room the player enters on the same layout? Each room would need its own 4 containers that go to their own specific computer that goes to its own specific door to unlock. How would you go about doing this with construct? Im thinking it has to do with containers, but I'm not sure where to go from there.

    Can anyone help me figure out a way to do this?

    OH, and one more question. If you have alot of instances that look like boxes does it save CPU to make collisions BoundingBox instead of Per Pixel? or does that matter?

  • You could do it with containers, sure. Put each key (you will have to make four different ones), a computer, and a door in to a container.

    I don't know how you have the keys set up, so I couldn't exactly say how you should make them, but if you do something like this for the doors it should work fine

    +computerSprite.Value("unlocked") = "yes"
      -doorSprite: Set animation to "Open"
    [/code:2hsp6q2z]
  • What I'm pushing for is that when you open one of the containers it gives you the first number of the 4 digit password for the computer and then the next in another container and so on. How would you randomly generate that number and then have digits assigned to each container?

  • Make some value on the computer - say "code"

    start of level -> set code to random(10000)

    Give the boxes another value "digit" which will be the digit they show when opened

    set each box's initial value digit value to numbers from 0 to 3, each with a unique value, (The effect of this is that the 0 box will show the 1st digit, the 1 will show the 2nd etc)

    add a sub-event to the start of level event:

    for each box -> set digit to middle(zeropad(computer.value('code'),4),'digit',1)

    EDIT: (actually this for each box might not be necessary, can probably just put the action in the start of level event)

    You may have to set the initial values to 1 to 4, I dunno if 0 or 1 in that parameter of the middle expression gives the first digit. Try this if it doesn't work.

    This is also assuming you're only having one of these doors, would be more complex with multiple ones, but doable by adding another value to the boxes and setting them to the computers UID (or a corresponding extra value on the computer. EDIT: or indeed with containers but then you'd have to make different objects for each box and use a family for the stuff above, which is a bit messier).

    When you need to display the digits, the value you need is 'digit', the value to test if its correct is computer's 'code' value.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks I'm trying that now.

  • oh the actual expression is "mid" not "middle"

    and you do need to set them from 1-4 not from 0-3

    Oh and, this is how you set it up for multiple instances using an ID value like I was saying, just make sure the initial ID values of the boxes are the same as the matching computer ID value.

    <img src="http://www.quotecats.com/what/ComputarID.PNG">

  • Ok im not sure if I did it right but when I run it the only numbers the boxes are showing is 1 but the computer does generate a code

  • Did you set it up like that screenshot above? I had it working.

    You also have to make sure the initial values are right:

    so if you have 2 computers and 8 boxes you'd have as initial values

    COMPUTER1: ID=0 Code=0

    BOX1: ID=0 Digit=1

    BOX2: ID=0 Digit=2

    BOX3: ID=0 Digit=3

    BOX4: ID=0 Digit=4

    COMPUTER2: ID=1 Code=0

    BOX5: ID=1 Digit=1

    BOX6: ID=1 Digit=2

    BOX7: ID=1 Digit=3

    BOX8: ID=1 Digit=4

    MORE COMPUTERS - just change the ID values.

    The initial digit value corresponds to which digit that box will display (ie Digit=1 means it will display 1st)

  • to the computers UID right? because for some reason any event I have that uses a UID doesnt work, Im using .97.4 should I get the newest version?

  • I suppose you can use UID's but I usually find it easier, when placing loads of objects in the layout, to just set the initial values manually for each object. It's very easy to change, and very simple. It can get very confusing when using UID's to know what object goes with what in the layout editor.

    I made an example for you: http://www.quotecats.com/what/computercode.cap

    You know the objects with the same ID value go together. So if a computer has ID 1 it will go with boxes with ID 1. You set this in the layout editor, making it really easy to see what you're doing.

    Similarly you have to set the boxes initial digit value to determine which of the 4 digits you want. (It's probably possible with a little more tinkering to make the computer able to handle codes of arbitrary length, only if you need it though as it'd make it more complex.)

  • OH ok I thought u meant to use the UID of the computers that probably screwed everything up

    Got it its working perfectly thanks alot only one thing tho, where would I put an event to make sure the number is above 999, i have the computers set to random(9999)

  • I'm having a little trouble with putting in an editbox so the player could type in the numbers corresponding to the code. I cant make the box invisable and I dont think theres a way to make it so when they press enter it checks the answer.

  • Got it its working perfectly thanks alot only one thing tho, where would I put an event to make sure the number is above 999, i have the computers set to random(9999)

    You don't need to, basically thats what zeropad does

    if its <1000 say like 420

    then zeropad would make it 0420 so all it'll mean is the first digit is 0

  • k whatever who cares about weed day, I have an editbox inserted but everytime I enter the right number for the computer it wont destroy the door... man should I upload .cap or something?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)