im working on a texted adventure where the user can walk around a map to solve puzzles. im using a switch to move. if a player can only go east, west or south from the room they are in i have a default for if they try to go north. my problem is that when they go into the defualt it kicks them out of the program. i tried putting the switch into a while loop that should repeat until they enter a valid answer but it goes into infinite loop if they go into the default. i dont understand why its doing this. is my loop wrong or am i going about it the wrong way? my switch with the loop is below. the letters represent the direction they are going.
Code:
int x=0;
while (x!=1)
{
switch(direction)
{
case 'e':
case 'E':
x=1;
room3();
break;
case 's':
case 'S':
x=1;
room5();
break;
case 'w':
case 'W':
x=1;
room1();
break;
default:
x=0;
cout << "not a choice\n";
}
}