Quote:Original post by DeathsBargin
*** Source Snippet Removed ***
1) I need to know how I make it, so that when they take the gun, gunnin = true.
2) Is there a way to make it so that it repeats the room description on its own on else. Or do I have to redo the description every time manually?
3) I want the while loop to make it loop forever. Is it the way it should be? If not how do I make it do so. (I need a loop to make the program not stop untill I tell it to(terminate)).
Thanks,
Death
Ok, good.
An infinite loop looks like this:
while (true){ //do your stuff ;)}
But might want to terminate it, so it could look like this:
while (true){ if (userQuits == true) break;}
break; just tells the loop to stop.
I see you have this: while (dmover == false);
What you want is this:
while (dmover == false){ if (userQuits == true) dmover = true;}
QUESTION #1:
You have something like this:
if (plan == 1){ cout<<"...in the room stuff...";}
You can simply something like this:
bool gunTanken = false;//or whateverif (plan == 1){ cout<<"You take the gun..."; gunTaken = true; // you make the gunTaken variable true, meaning that the // user took the gun...}
QUESTION #2:
I'm not sure exaclty how you want it. Here's a heavily commented example:
int dir = -1;do // a do {} while () loop...{ // begin it! cout<<"Your description...\n\n"; // ask the user where he wants choice 1, 2,or 3 cout<<"Do you want to go:\n1) Left\n2) Right\n3) Up\n"; cin>>dir; // get the user's choice} while (dir != 1); // do this until the user enters 1
QUESTION #3
Well, if you want the game to repeat:
bool b_GameOver = false;char answer;while (b_GameOver == false){ // do your stuff ;) cout<<"Quit? (y/n): "; cin>>answer; if (answer == 'y' || answer == 'Y') b_GameOver = true;}
That would run and if the user says 'y' then then the loop would quit.
Hope I helped! [grin]