Passcoded Doors

For questions about using Classic.

Post » Sun Sep 28, 2008 11:23 pm

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. :cry:
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?
B
2
S
2
G
4
Posts: 239
Reputation: 1,928

Post » Sun Sep 28, 2008 11:47 pm

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

[code:2hsp6q2z]
+computerSprite.Value("unlocked") = "yes"
-doorSprite: Set animation to "Open"
[/code:2hsp6q2z]
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Sep 28, 2008 11:52 pm

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?
B
2
S
2
G
4
Posts: 239
Reputation: 1,928

Post » Mon Sep 29, 2008 12:34 am

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.
B
2
S
2
G
5
Posts: 236
Reputation: 2,122

Post » Mon Sep 29, 2008 12:47 am

Thanks I'm trying that now.
B
2
S
2
G
4
Posts: 239
Reputation: 1,928

Post » Mon Sep 29, 2008 12:48 am

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.
B
2
S
2
G
5
Posts: 236
Reputation: 2,122

Post » Mon Sep 29, 2008 1:17 am

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
B
2
S
2
G
4
Posts: 239
Reputation: 1,928

Post » Mon Sep 29, 2008 11:25 am

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)
B
2
S
2
G
5
Posts: 236
Reputation: 2,122

Post » Mon Sep 29, 2008 2:05 pm

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?
B
2
S
2
G
4
Posts: 239
Reputation: 1,928

Post » Mon Sep 29, 2008 2:50 pm

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: [url:w5bqo14r]http://www.quotecats.com/what/computercode.cap[/url:w5bqo14r]

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.)
B
2
S
2
G
5
Posts: 236
Reputation: 2,122

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests