Wondering about if statements

Pages: 12
Thats not what I meant, admkrk, and my thing is already solved. It involves a while true loop, with the if statements inside, and continue statements at the end of each if.
There is no such thing as a while true loop.
I suspect he means
1
2
3
4
while(true)
{
    //...
}
ispil: Indeed. its never too early to learn proper terminology however
Sorry about my bad terminology Ispil, I just wanted to say my thing was solved.
Depending on [integer] count's value, you go into the specific if statement which gives a situation and then changes count.

You've described a simple state machine. You can implement this with a while loop and a switch statement:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
while (true) {
    switch (state) {
    case 0:
        do stuff;
        state = 3;
        break;
    case 1:
        do other stuff
        if (blah blah) {
            yadda yadda
            state = 0;
        } else {
            yabba dabba doo.
            state = 3;
        }
        break;
    case 3:
        more stuff
        state = 1;
        break;
    }
}

If this looks good then use an enum to represent the state instead of an integer. The enum names can be a lot more meaningful.

Thanks, that works too!
lol, but it was wrong when I said the same thing, I just did not provide a code sample.
You never said the while loop part, which was the main thing needed there.
The title of this topic is "Wondering about if statements", and that was what I was referring to. I was also going by your question:
I am making a text adventure game, that uses a lot of classes, and definitely if statements. So mu question is this: Is there a way to 'break' out of an if statement, like the continue keyword for loops? I want this so I can go up the evaluation order for like a player going up to another room.

You only mentioned a loop as an example of how you wanted to change the flow.

I am not offended, or intending to offend, just saying.

Topic archived. No new replies allowed.
Pages: 12