Hey this is my first time using this site can someone help me with where am going wrong with this. I am trying to create a text based adventure but my switch statements in an if statement. First of all i would like it output the cout statements which is attached to the each switch statement as well as update the different integers that i have stated in the code;
{
int caveKey = 1; // Key Count in Cave
int campsiteKey = 1; // key count in campsite
int riverKey = 1; // key count in river
int playerKey = 0; // Players inventory
int currentLocation = 1; //location of player 1: beach 2:Cave 3:forest 4:campsite 5:montain range 6:river 7:gate
std::cout << "Welcome weary travaler, your stuck in a little maze of mine for my amusment. You must find the 3 keys to unlock the gate";
if (currentLocation = 1) {
std::cout << "Your on the beach Press 1 to go north Press 2 to go East Press 3 to check your key count ";
switch (1)
{
case 1: { std::cout << "Going west";
currentLocation = 3; }
break;
case 2: { std::cout << "Going East";
currentLocation = 2; }
break;
case 3: { std::cout << "You have " << playerKey << "s "; }
break;
default: {std::cout << "Please select an appropriate value"; }
break;
}
if (currentLocation = 2 && caveKey = 1) {
std::cout << "Your in the cave Press 1 to go west Press 2 Search rocks Press 3 to check your key count ";
switch (2)
{
case 1: { std::cout << "Going West"
currentLocation = 1; }
break;
case 2: { std::cout << "You find a key"
caveKey = 0;
playerKey++; }
break;
case 3: { std::cout << " You have " << playerKey << "s "; }
break;
default: {std::cout << "Please select an appropriate value"; }
break;
}
}
}
system("pause");
}
Aucun commentaire:
Enregistrer un commentaire