0 Favourites

Condition with order

  • Hi everyone

    i am new on construct 2, and what i want to do is simple, but i have no idea how to do it

    here is an exemple of what i want to do, to see the full picture

    you have to play a melody to solve the puzzle

    the melody order is : C+E+C+D

    when the puzzle solved then a congratulation text appear

    please help i really don't know what to do

    here is the capx : [quote:1lhlu4r2]https://dl.dropboxusercontent.com/u/138507172/piano_puzzle.capx

    thank you very much

  • I made three sprites into one, so they have same instance variable name.

  • Thank you alextro, but what i wana do is a little diferent

    i want to have seperate images not all in one, so i can put a sound on mouse clicked and other things

    thank you for your help

  • If you have an acces to using family behaviour, you may use family instance variable and keep objects separated. Either It is more simple to handle different images within single object type. Put different sound or something else should not be a problem, since you can distinguish images via animation name & frame.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • alextro, i don't know how to use the family instance variable fo this case

    what i can't do is add an & to a condition like this :

    If

    i do this

    &

    do this

    &

    do this

    Then do this

    maybe with a capx i undestand better ^^

  • here is an exemple of what i want to do, to see the full picture

    you have to play a melody to solve the puzzle

    the melody order is : C+E+C+D

    when the puzzle solved then a congratulation text appear

    please help i rearly don't know what to do

    here is the capx : dl.dropboxusercontent.com/u/138507172/piano_puzzle.capx

  • Sounds like you do something like:

    Variable - pp (puzzleprogress)

    C clicked

    - If pp = 0 or 3

    - if pp = 0 then pp = 1

    - if pp = 3 then pp = 4

    else

    - pp = 0

    E clicked

    - If pp = 1 then pp = 2

    else

    - pp = 0

    D clicked

    - If pp = 3 then pp = 4

    else

    - pp = 0

    If pp > 3 - CELEBRATE!

    Something like that. There might be a more elegant way to solve this, but with a small puzzle like this, this approach should work.

  • thank you for your quick comment Somebody

    i tested with your code but nothings is happend, maybe i forget something

    here is the capx with your events : [quote:1uf9q9xz]https://dl.dropboxusercontent.com/u/138507172/piano_puzzle_2.capx

  • Fixed it for you - pay attention to "ELSE" position - it is important and also do not group the conditionals, like pp = 0 together with pp = 2 as in this case it will never trigger when one of them has the right value.

    Also, this is a good idea when doing something like this - run it in debug and watch the pp variable - how it changes after each click - that way you can see in which step something is wrong.

    Enjoy.

  • Ohhh thank you very much Somebody! it works you made my day

    now i have to understand the mechanism of your code to use it in other things

    thanks everybody for your help

    Edit : and thank you trultz i can't reply in the private message they told me i don't have enough reply i think

    for the moment i don't have mic, please send me your fb or twitter

  • Glad to help. The mechanism is simple - as you see every "good" action moves our progress forward, every "bad" (else) actions drops it down to 0. If we have repeatable "good" actions then we need to first check if a previous "good" action has taken place, then figure out if we are in the right order.

    You just need to plan out the actions and you are good to go.

  • Hunter

    I don't know if you still need updated example with family implemented from last capx I gave you, but anyway here it is:

  • alextro Thank you very much alextro, your exemple with family is very useful i will use it in some puzzle for my game =)

    @somebody i tested another condition with 4 click, it works fine, but when i try to add more clicks it doesn't work, for exemple here is my capx for 6 click, i follow the same procedure but i think i forget something

    [quote:3sxt4ev9]https://dl.dropboxusercontent.com/u/138507172/Puzzle_6_click.capx

  • Hey, Hunter - you should use debug to find a problem point, like this (use Debug Layout):

    We see that first of all, since there are both those events one after another the pp value gets set to 2 right away - you might need some kind of an extra variable there. And then it gets set to 0 on next click so there's some problem in that event.

    Now that you know how to better find these problem points you should manage the rest.

  • I gave your problem a shot. Take a look at my capx.

    All you have to do to add more keys is add the new sprite to the Keys family and set the ID variable to the key name. Then in the events add to the array index the puzzle combination you want and increase the size of the array. Let me know if you have an issue with any of that.

    If you just want to keep using the same three keys then all you have to so is change the puzzle combination in the events page. Just add to the array.

    Check it out.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
46 3,560
Geo's avatar
Geo
Unread hot topic
0 Favourites
Place the picture in order Game
36 6,430
NECROKRIEG's avatar
NECROKRIEG
Unread hot topic
34 1,749
TheDoctor's avatar
TheDoctor