void Forest::enterForest(){
int input = 0;
bool choice = true;
cout << "Now Entering: Deep Forest" << endl;
cout << "Beware, not all levels have an exit" << endl;
cout << "---------------------------------" << endl;
do {
cout << "Deep Forest Menu" << endl;
cout << "1. Go North" << endl;
cout << "2. Go South" << endl;
cout << "3. Go East"<< endl;
cout << "4. Go West" << endl;
cout << "5. Go North West" << endl;
cout << "6. Go North East" << endl;
cout << "7. Go South West" << endl;
cout << "8. Go South East"<< endl;
cout << "9. Cheat Sheet (temporary)" << endl;
cout << "10. Show Location (temporary)" << endl;
cout << "11. Show Stats" << endl;
cout << "12. Click your heels" << endl;
cout << "---------------------------------" << endl;
cin >> input;
switch (input){
case 1:
moveInForest("North");
choice = true;
break;
case 2:
moveInForest("South");
choice = true;
break;
case 3:
moveInForest("East");
choice = true;
break;
case 4:
moveInForest("West");
choice = true;
break;
case 5:
moveInForest("North West");
choice = true;
break;
case 6:
moveInForest("North East");
choice = true;
break;
case 7:moveInForest("South West");
choice = true;
break;
case 8:
moveInForest("South East");
choice = true;
break;
case 9:
displayForest();
choice = true;
break;
case 10:
showPlayerLocationInForest();
choice = true;
break;
case 11:
player->showCurrentStats();
choice = true;
break;
case 12:
input = 12;
choice = false;
break;
}
}while((choice == true) && (playerIsNotDead == true));
I look at my variable list while debugging and it shows that both choice and playerIsNotDead are both true an yet still exits the do while loop. What am I doing wrong?
when a player moves in forest they have a chance for a mob to spawn and attack them (very primitive code so far)
this is in forest.cpp
1 2 3 4 5 6 7 8 9
void Forest::chanceToBattle(){
int r = rand()% 3 + 1;
if (r = 1){
cout << "A Giant Wasp Attacks!" << endl;
cout << "You hit it for 15 damage, killing it. You took 15 damage" << endl;
player->takeDamage(15);
playerIsNotDead = player->checkIfAlive();
}
}
so playerIsNotDead is set equal to true if the player is not dead. Although when I run the code I get choice = true and playerIsNotDead = true(204)
in the locals
Hmmm. I can't seem to find the solution to your problem with a quick glance at your code, but I did noticed that line 3 of your forest.cpp file has a little mistake (probably a typo).
void Forest::enterForest(){
int input = 0;
bool choice = true;
cout << "Now Entering: Deep Forest" << endl;
cout << "Beware, not all levels have an exit" << endl;
cout << "---------------------------------" << endl;
do {
cout << "Deep Forest Menu" << endl;
cout << "1. Go North" << endl;
cout << "2. Go South" << endl;
cout << "3. Go East"<< endl;
cout << "4. Go West" << endl;
cout << "5. Go North West" << endl;
cout << "6. Go North East" << endl;
cout << "7. Go South West" << endl;
cout << "8. Go South East"<< endl;
cout << "9. Cheat Sheet (temporary)" << endl;
cout << "10. Show Location (temporary)" << endl;
cout << "11. Show Stats" << endl;
cout << "12. Click your heels" << endl;
cout << "---------------------------------" << endl;
cin >> input;
switch (input){
case 1:
moveInForest("North");
choice = true;
break;
case 2:
moveInForest("South");
choice = true;
break;
case 3:
moveInForest("East");
choice = true;
break;
case 4:
moveInForest("West");
choice = true;
break;
case 5:
moveInForest("North West");
choice = true;
break;
case 6:
moveInForest("North East");
choice = true;
break;
case 7:moveInForest("South West");
choice = true;
break;
case 8:
moveInForest("South East");
choice = true;
break;
case 9:
displayForest();
choice = true;
break;
case 10:
showPlayerLocationInForest();
choice = true;
break;
case 11:
player->showCurrentStats();
choice = true;
break;
case 12:
input = 12;
choice = false;
break;
}while((choice == true) && (playerIsNotDead == true));
}
see if this works I couldn't see much since I dont know your functions but at least it seems that your do...while is not correctly posted, its a logic error.
the while condition should be on the main brace, its right after the do...
I am nearly positive it has something to do with my bool being true(a number) rather then just true when I look at the locals. I can't find any forum postings about this, anyone know?