Condition with order

0 favourites
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • thatserafimkid - nice, elegant solution. Certainly a good choice for longer puzzles or if there are many more planned.

  • Somebody

    Thanks, I figured eventually he would want to do expert mode and have a whole keyboard set. LOL

    Hunter

    I updated your puzzle one step further and made the puzzle text display what was in the array. So instead of changing the text to match the puzzle you create in the array it will do it for you.

    Alternatively with this method you can set the puzzle to be generated randomly. Shouldn't be to hard. I'll let you figure that one out if that's something you'ld like to do

  • Somebody

    Thanks, I figured eventually he would want to do expert mode and have a whole keyboard set. LOL

    "Play this symphony to continue!"

  • Thank you thatserafimkid and somebody for your help, but i'm afraid i have no idea how to use array ^^' for the moment i will use somebody's logic on variables, i think i understand his method, i use debug too to understand what's going on, i use the debug on 2 click in one key with 2 variables, but i didn't succeed, here is my capx :

    [quote:x1wdw42l]https://dl.dropboxusercontent.com/u/138507172/puzzle_2_click.capx

    if i just knew how to put 2 clicks in one key, it will be great

    the puzzle is C+C =)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hunter

    In my example if you want to just keep the three keys you already have all you have to change is the combination in the start of lay out event.

    It'll be easier for you in the long run.

    just change this code.

    if you only want two keys in the puzzle just have the top two. And change the value to whatever letter you want in the puzzle.

    So if you wanted C+C the code would be this:

    Then all you have to do is select the array object and on the right properties menu you change the width of the array to equal how many keys in you puzzle.

  • Thank you thatserafimkid for such details =)

    it seems so easy but i have no idea how you create family ID and if you add instant variable to the array or not

    here is my capx, i know it's missing a lot of things, but that's all i understand ^^':

    https://dl.dropboxusercontent.com/u/138507172/puzzle_array.capx[/code:1eu7rx05]
  • Hunter

    You are close. Perhaps using a variable with name "ID" was a little confusing because it seems you've mistaken it for Object ID or UID.

    So in the Keys family you want to create a Text instance variable you can call it KeyName to make it easier for you. You don't have to create a separate variable for each key.

    Then click each key sprite seprately and you will see that they each share the new KeyName variable. You can change the variable value for each key sprite separately so then you can refer to them specifically in your code. So lets say for your C key object sprite you would set the value of KeyName to C. Do that for each of your other letters.

    Then in your code when Families 'Keys' is pressed you compare the KeyName variable. If it equals "C" then you play sound for the C key and so on.

    The array is just an easy way to hold multiple values. In your case because you want to hold multiple key combinations to solve your puzzle an array is the best option.

    An array has indexes which refers to the location you want something stored. It begins with 0 and goes on for however many things you need to store.

    So what you would do is in the start of layout is set each index beginning with 0 to the key combination you want. So if you wanted you puzzle to be DEC.

    You would

    set index(0) to "D"

    set index(1) to "E"

    set index(2) to "C"

    As you can see we have three items in our array so you would change the array width to 3 so it knows its holding 3 things. If you add more then you need to change the width to however many keys you have.

    Let me know if your still confused on any of this.

  • thatserafimkid

    If I am not mistaken, you can use tokenat to store key order as an alternative to array especially for 1D array.

  • Either way thatserafimkid deserves some kinda of a little medal for that explanation post.

  • Yeah you are right somebody, thatserafimkid thank you for your explanation very detailed

    i understand now the logic of arrays, i have just a litle problem for my puzzle, it is that i want the player to continue clicking on other keys even if he change the order, so i add this to the event sheet :

    but the problem now is that even if i do this : C+E+C+C+C+D+D+E or C+E+C+D+D+D+E i can succeed

    and what i want to do is leave the player the choice to play what he want but he succeed only if he play the right keys

    here is my capx :

    https://dl.dropboxusercontent.com/u/138507172/puzzle_array2.capx[/code:eiswhsuh]
  • Simplified it a whole bunch and put each key into one object. You could change the array.AsJSON to a loop within the array to tell the user exactly which keys they got wrong on each attempt.

    EDIT: Didn't see the second and third page of replies, woops. If this helps at all go ahead and use it, if not just ignore

  • You just have to repopulate the array once you get order wrong. Check out the capx. I did this by putting the array populate inside a group. The group gets activated on start so the array is already populated once you start the layout. But I also reactivated it if the key you pressed is not the next one on the list. You dont need the extra code to play the sound on every click. I removed that since it was already in there. I just took it out of the nested Key.ID condition.

    Somebody

    Aha thanks. I just like helping people out. He happened to get me on a day I'm not busy.

  • alextro

    That would be a really clean solution for this case. You would be right. I suppose it depends on how Hunter wants to use it.

    But in any case I went a head and created an example with tokenat instead of using an array. Check it out Hunter. All you have to do to change the puzzle is change the variable 'puzzle' to have the letters in the order you want. And then change where it says keycount = 6 to however many letters you have in your puzzle. Might be easier for you.

    Edit: I found a bug in the last capx I uploaded. If you hit the first key in the pattern twice to start off with it wouldn't continue the pattern. You would have to click one of the other keys first then start the pattern again.

  • Excellent thatserafimkid your sample give me an idea how to build dialogue system such as rpg or vn game.

  • alextro

    You are very welcome. Glad I could provide some inspiration

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