While function not stopping

My while loop isn't stopping and the function only works some times any suggestions or fixes
#include <iostream>
#include <windows.h>

using namespace std;


int main() {
system("CLS");
bool walkBool= true;
int expSum;
int enemySum = 20;
int playerSum = 40;
int playerDamage= 5 ;
int zorgDamage = 3 ;
int playerHealth;
int zorgHealth ;
int attackChoice;
int retry;
int walkChoice;
int startingChoice;
int money = 0;
int level = 1;
int moneyPlus = 0;
int exp = 0;
int plusExp = 5;
int levelOne = 10;
int levelTwo = 15;
bool gameOff = false;
bool gameOn = false;
bool playerWalk = false;
bool playerJump = false;
cout <<" -------------------------------\n";
cout <<" Welcome to the simulation game!\n";
cout <<" -------------------------------\n";
cout <<" What would you like to do?\n\n";
cout <<" [1] - Play\n";
cout <<" [2] - Exit\n\n";
cout <<" Enter a key ";
cin>> (startingChoice);
if(startingChoice == 2){
system("CLS");
system("PAUSE");
return 0;
};
if(startingChoice == 1){
bool gameOff = false;
bool gameOn = true;
if (gameOn == true){
system("CLS");
cout<<"\n\nYou wake up in an unknown world, you have no recolection of anything, and you\ncan't walk.You need shoes there are a pair of shoes sitting on the table do you take them?\n\n [1]-Yes\n [2]-No\n\n Enter a key ";
cin>>(walkChoice);
if(walkChoice == 1){
system("CLS");
cout<<"An alien soldier saw you take them he thinks you're stealing.\n\nHe engages in batttle!\n";
walkChoice = true;
system("PAUSE");
system("CLS");


while (walkBool = true){

playerHealth = playerSum;
playerSum = playerHealth - zorgDamage;
zorgHealth = enemySum;
enemySum = zorgHealth - playerDamage ;
if(enemySum == 0) {
walkBool = false;

system("PAUSE");
system("CLS");
cout<<"Hello World";
}
cout<<"What would you like to do?\n\n[1]Attack\n\nHealth = "<<playerHealth<<"\n\nZorg Health = "<<zorgHealth<<"\n\nEnter a key" ;

cin>>(attackChoice);
if(attackChoice == 1){
system("CLS");

cout<<"You attacked the Zorg it did "<< playerDamage <<" ammount of damage to the zorg\n";
system("PAUSE");
system("CLS");

cout<<"The zorg attacked you it did "<< zorgDamage <<" Ammount of damage to you\n";

system ("PAUSE");
system ("CLS");}



}
if(walkChoice == 2){
system("CLS");
bool gameOn = false;
bool gameOff = true;
cout<<"You didn't take the shoes therefore you couldn't walk.\nAn alien then came in and killed you\n\nRetry?\n\n [1]-Yes\n [2]-No ";
cin>> (retry);
if(retry == 1 ){
bool gameOn= false;
bool gameOff = true;
while(playerWalk == false){
system("CLS");
main();}
};
if(retry == 2){
system("CLS");
system("PAUSE");
return 0;
};
}
;}
}
};

system("PAUSE");
return 0;
}
Suggestion 1: put your code inside code tags, they looks like <> on panel to the right
Suggestion 2: tell us with which while loop you have problem
The while walkBool isn't working after enemy sum is 0 it will continue running
while (walkBool = true){You are setting walkbool to true here, so it can never be false.
OMG Thank you feeling so stupid. Well then again I am only thirteen
Topic archived. No new replies allowed.