I am having trouble making a menu system for a text based adventure game I am creating. I don't really understand all of the concepts yet but I am trying to go to a new situation by setting a number to be a certain situation and then by picking a certain action making the progress variable equal to that new situation but it doesn't seem to work and it merely loops around to the next (except for the first menu).
TLDR: My code doesn't work!
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main ()
{
int choice;
int loop;
loop = 1;
while(loop==1)
{
system ("CLS");
cout << "****Patrick's Awesome RPG!****\n\n"
<< "1. Start Game\n"
<< "2. Instructions(Read this first!)\n"
<< "3. Info\n"
<< "4. **EXIT**\n\n";
cin >> choice;
switch(choice)
{
case 1:
loop = 2;
case 2:
case 3:
case 4:
if(choice==4)
{
exit(0);
}
}
}
while(loop==2)
{
system("CLS");
cout << "You find yourself in complete darkness. You do not know where you are or how you got here. What do you do?\n\n";
cout << "1. Start feeling around in order to figure out where you are\n";
cout << "2. Start crying\n";
cout << "3. Start running around blindly\n";
cout << "4. Listen to your surroundings\n\n";
cin >> choice;
switch(choice)
{
case 1:
system ("CLS");
cout << " You slowly start to crawl and feel your way around in the inky blackness. the ground you are on feels like rough cobblstone and the place is damp and musty. You feel like you are in some sort of dungeon. Suddenly you feel something warm and hairy and it appears to be alive!\n";
system ("PAUSE");
loop = 3;
case 2:
system ("CLS");
cout << "You start weeping loudly untill you hear a scratching sound and you are suddenly devoured!\n\n";
system ("PAUSE");
loop = 0;
case 3:
system ("CLS");
cout << "You start running around in a panic untill you bump into something. That something swallows you whole\n\n";
system ("PAUSE");
loop = 0;
case 4:
cout << "You listen intently to the complete and utter silence untill you hear a slight rustling and snoring sound, something alive is with you!\n";
system ("PAUSE");
loop = 2;
while(loop==0)
{
system ("CLS");
cout << "You Are Dead\n";
cout <<"GAME OVER\n\n";
system ("PAUSE");
loop = 1;
}
}
}
}