Hello DaniWeb Users,
I am new to the forum however from what I have seen it is exceptionally good! I have searched the forums already and found various questions relating to a similar problem as mine however I am unable to work out how I can amend this for my problem. During web research I found various suggestions such as While loops (which I can't see how it can run in my piece of code), GOTO (which apparently is a big no) and Switch.
I am trying to make a Text Based Adventure Game to run in CMD as my first more advanced C++ project.
I am currently at the stage of creating the menu option however I am struggling to get it to return to the main menu once the user has selected their text colour through the GameOptions.
The code which I have so far for the menu is:
#include <iostream>
#include <string>
#include <windows.h>
int main()
{
using namespace std;
string Option;
cout << "\t********************************************************\n";
cout << "\t* Welcome to Dragon Slayer *\n";
cout << "\t* Please select your option now *\n";
cout << "\t* *\n";
cout << "\t* PlayGame GameOption Quit *\n";
cout << "\t********************************************************\n\n\n";
cin >> Option;
{
if (Option == "PlayGame")
{
string Name;
cout << "Great, let's get started!\n\n";
cout << "What is your name?\n";
cin >> Name;
cout << "\n\nHello " << Name << ", how are you doing? My name is Alexander.";
}
if (Option == "GameOption")
{
string Colour;
cout << "You are now able to change the text colour!\n\n";
cout << "Green\n";
cout << "Yellow\n\n";
cin >> Colour;
{
if (Colour == "Green")
system("Color 0a");
if (Colour == "Yellow")
system("Color 0e");
system("cls");
cout << "Sample Text\n\n";
}
}
if (Option == "Quit")
{
cout << "What a shame, I was looking forward to it\n";
return 0;
}
}
}
How would I get it so once the user has selected their colour (lines 35 to 53) it goes back to the original menu whilst keeping the colour they chose?
Thank you