Im trying to create a Text Based Game and i want to have a 'Game Menu'. This is my code but i dont know exactly how to make the menu. Please Help! I also wouldnt mind if some can tell me how i would be able to integrate a cheat into this.
#include "Library.h"
using namespace std;
void Intro();
void RaceClass();
void Cheats();
int main()
{
HANDLE hOut;
hOut = GetStdHandle (STD_OUTPUT_HANDLE);
SetConsoleTextAttribute (hOut, FOREGROUND_RED);
cout << "\t Vitium Victoria \n\n";
SetConsoleTextAttribute (hOut, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
cout << "Programmed by";
SetConsoleTextAttribute (hOut, FOREGROUND_RED);
cout << "\t Kile Exley \n";
SetConsoleTextAttribute (hOut, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
cout << "Written by";
SetConsoleTextAttribute (hOut, FOREGROUND_RED);
cout << "\t Bryan Exley\n\n\n";
SetConsoleTextAttribute (hOut, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
Intro();
SetConsoleTextAttribute (hOut, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
cout << "\n\n";
system("PAUSE");
return 0;
}
void Intro()
{
HANDLE hOut;
hOut = GetStdHandle (STD_OUTPUT_HANDLE);
char charName[32];
int userRace;
int userClass;
char gmOption;
cout << "Welcome to the world of Vitium Victoria!\n";
cout << "Here you shall find adventures and horrors alike.\n";
cout << "The world is brimming with nightmares waiting to be dreamt;\n";
cout << "treasures and quests waiting to be sought, and fantastical journies to be had!\n\n";
SetConsoleTextAttribute (hOut, FOREGROUND_RED);
cout << "\t Game Menu\n";
SetConsoleTextAttribute (hOut, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_GREEN);
cout << "1 - New Game\n";
cout << "2 - Load\n";
cout << "3 - Cheats\n";
cin >> gmOption;
if (gmOption == 1)
{
RaceClass();
}
if (gmOption == 3)
{
Cheats();
}
}
void RaceClass()
{
HANDLE hOut;
hOut = GetStdHandle (STD_OUTPUT_HANDLE);
char userRace;
char userClass;
char charName;
cout << "What is your name?\n";
cin >> charName;
cout << "Hello, ";
SetConsoleTextAttribute (hOut, FOREGROUND_RED);
cout << charName;
cout << "\n\n";
SetConsoleTextAttribute (hOut, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
srand ( time(NULL) );
userRace = rand() % 8 + 1;
userClass = rand() % 6 + 1;
//Human
if (userRace == 1 && userClass == 1)
{
cout << "You are a Human/Wizard!\n";
cout << "Okay, "<< charName << " your race is Human and your class is Wizard. This information is very important! - You can refer to it at any time by typing 'stats'.";
SetConsoleTextAttribute (hOut, FOREGROUND_RED);
cout << "8 Health - 17 Mana - 5 Attack\n";
SetConsoleTextAttribute (hOut, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
}
}
void Cheats()
{
HANDLE hOut;
hOut = GetStdHandle (STD_OUTPUT_HANDLE);
char cheat;
char charRace2;
char charClass2;
char charPro2;
cout << "Cheat Code:\n";
cin >> cheat;
if (cheat == 236)
{
cout << "You found the Pick Your Own Class and Race cheat!\n";
cout << "Choose a Race and Class and Profession from below.\n";
SetConsoleTextAttribute (hOut, FOREGROUND_RED);
cout << "Races:\n";
SetConsoleTextAttribute (hOut, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_GREEN);
cout << "Human\n";
cout << "Angel\n";
cout << "Dwarf\n";
cout << "Troll\n";
cout << "Demon\n";
cout << "Goblin\n";
cout << "Orc\n";
cout << "Elf\n";
cin >> charRace2;
SetConsoleTextAttribute (hOut, FOREGROUND_RED);
cout << "Classes:\n";
SetConsoleTextAttribute (hOut, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_GREEN);
cout << "Wizard\n";
cout << "Warrior\n";
cout << "Marksman\n";
cout << "Thief\n";
cout << "Rebel\n";
cout << "Paladin\n";
cin >> charClass2;
}
}