[SOLVED] How do I solve this conditional loop in C2

Get help using Construct 2

Post » Mon Jun 02, 2014 1:48 pm

Hello.
I haven't posted in a while as all the problems I've encountered were easily solved by just taking time and think but this one appears to be a showstopper for me.
I have a player object that collides with another object. On collision, the players stops for a designated period of time and the gesture control should take place.
What I need is give a player an ability to make any amount of tries while the player is stopped by previous condition. When time is up, the gesture control goes away and the players starts moving again.
So what I'm trying to achieve is basically a 2 nested while loops.
Pseudo code would look like this:
Code: Select all
string gesture = "None";
while (WaitForSeconds(10))
{
 
    while (true)
    {
       // Wait for the user to perform a gesture and record it
        gesture = GetInputGesture();
        if (gesture != "None")
             break;
    }
   // Do some gesture comparison stuff to increase score
}

In addition, this code does contain a problem of a "frozen" gesture. Timed "while" loop could already end, but the nested loop can infinitely wait for the gesture. This is also the problem to solve.
Is this possible?
Last edited by BORODA on Mon Jun 16, 2014 2:42 pm, edited 1 time in total.
B
8
S
3
G
2
Posts: 4
Reputation: 1,599

Post » Mon Jun 02, 2014 2:08 pm

You just need to remember that C2 is a looping script, similar to being a giant while-loop already. You can use the Timer behaviour to trigger an event when the timer expires, and variables and/or Groups to turn sections of code on or off. Just think how you would do this without the while-loops, as that is guaranteed to not work in C2.
ImageImageImage
B
71
S
21
G
221
Posts: 3,649
Reputation: 124,227

Post » Mon Jun 16, 2014 2:41 pm

Hello. Today I was finally able to produce a working event sheet that is doing exactly what I needed. Thanks for pointing a timer behavior for me.
Problem is solved.
B
8
S
3
G
2
Posts: 4
Reputation: 1,599


Return to How do I....?

Who is online

Users browsing this forum: TsubaRu and 4 guests