Best way to handle unlocking doors

In my game I am going to have several locked doors to open. What is the best way to do this...I am thinking tables but not sure how to accomplish it using tables.

Any Ideas?

Comments

  • BellowBellow Bartender Member, PRO Posts: 227

    use game attributes.

    create game attribute boolean name open

    give this rule to door

    if attribute game.open is true

    open this door

    else

    lock this door.

  • quinn221quinn221 Member Posts: 280

    @Bellow Yes I could use game attributes. But lets say I have 50 doors, won't that mean I will need 50 game attributes?

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    What are the conditions that allow the door to be opened? This would define the method. You could use either tables or self attributes.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    @Bellow said:
    use game attributes.

    create game attribute boolean name open

    give this rule to door

    if attribute game.open is true

    open this door

    else

    lock this door.

    It's never a good idea to use booleans an otherwise. They are susceptible to looping in those situations.

  • RabidParrotRabidParrot Formally RabidParrot. Member Posts: 956

    Tables will work for sure. Just set up a Unlock table. Give the table as many rows as you have doors. Make the row an integer. For every locked door change the attribute to 0. For every unlocked door change the value to 1.

    When the table cell value of door 1, (tablecellvalue,1,1) = 0 don't allow user to enter.

    When the table cell value of door 2, (tablecellvalue,2,1) = 1 allow the user to enter.

    That simple.

  • quinn221quinn221 Member Posts: 280

    @Lost_Oasis_Games The door will open once the Hero collides with the door...as long as he has the key

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    Okay so so that is easy. Use a self attribute to define which key level can open the door. This way you can make one prototype and just modify the self attribute.

    So let's say you have one attribute that will keep the key level. So for each key collected we add +1 since I'm sure this is a progression.

    Self attribute in door Key.level

    Rule

    When hero overlaps and collides
    When game.key => self.key.level

    Open door.

    Otherwise

    Timer after

    1 second do not check run to completion.
    Close door.

  • quinn221quinn221 Member Posts: 280

    @Lost_Oasis_Games thanks again!

Sign In or Register to comment.