I am trying to make a if else pathway with c++. What I want to happen is when I choose Anakin, then the bool "Anakin" will = true, then "if Anakin == true" it will output the desired code, and when I choose Heather, then "Anakin == false" and it will do the same. Except when I choose "Heather", it outputs the code as if I chose "Anakin":
bool Anakin;
char Name[25];
string choice;
int GameState = START;
int iRoomCounter[4] = {0,0,0}; // Used to determine if a room has been
visited.
int main() {
cout << "" << endl;
cout << "\t\t\tNimbus Town" << endl;
cout << "What is your name?" << endl;
cout << "Name: ";
cin >> Name;
cout << "All right " << Name << ", I will let you choose a friend that will be with" << endl;
cout << "you along the way, okay? Great." << endl;
cout << "Now choose your friend:" << endl;
cout << "• Heather" << endl;
cout << "• Anakin" << endl;
cin >> choice;
if (choice == "Heather") {
Anakin == false;
cout << "You chose Heather, good choice!" << endl;
}
if (choice == "Anakin") {
Anakin == true;
cout << "Anakin, what a great choice!" << endl;
}
while(GameState != DEATH)
{
switch(GameState)
{
case START:
{
if (iRoomCounter[0] == 0) {
if (Anakin == true) {
cout << "\n'Hello, welcome to Nimbus town.'" << endl; cout << "You jolted awake as an older, white-haired" << endl;
cout << "man greeted you. He was in a white tuxedo." << endl;
cout << "'My name is Kieran. What about you?'" << endl;
cout << "My name is " << Name << "." << endl;
cout << "Well " << Name << ", it's nice to meet you." << endl;
cout << "\nsomething doesn't feel right about him, but it's probably" << endl;
cout << "because I'm new here, you thought." << endl;
iRoomCounter[0] = 1;
if (Anakin == false) {
cout << "Anakin is false." << endl;
}
}
}
}
}
}
}
I'd appreciate it if someone told me what I'm supposed to do or give advice/code to help me. Thank you!
Aucun commentaire:
Enregistrer un commentaire