0

I understand that bool means true and false.
If I was doing a while loop...

while(!GAMEOVER)
do all this...
GAMEOVER = 1 or TRUE (loop exits)

IS the above correct? And is there any other ways bools are used to help reduce clutter?

Thanks,
Derek

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by dadam88
0

You'll have to make sure you set GAMEOVER to false before you start the loop.

Also, the loop doesn't stop as soon as game over is set to true. For example

while(!gameover)
{
//some stuff

gameover = true;

//more stuff

}

In that example, more stuff will be run even after gameover is set to true, it has to get to the end of the loop to then go to the beginning of the loop and check the condition.

Hope that helps,

David

0
while (!gameover) /*sets it to false right?  or do i have to GAMEOVER = FALSE instead of !gameover?*/

Clears up a little smog, thanks
Just put gameover = true at end of loop and it will work like I want it.

Edited by dadam88: n/a

0

No no, while(!gameover) does NOT set game over to false. It is saying "while gameover is equal to false". This is CHECKING its value, not SETTING it. You could exactly equivallently write while(gameover==false) . Note the double '=', this is c++ for "comparison".

DO NOT do while(gameover=false) . This DOES set gameover to false and this will DEFINITELY not work as you expect.

David

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.