Advertisement
Verzingz

C++ Text Game (Number Guess)

Feb 4th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3. #include <string>
  4. #include <random>
  5. #include <ctime>
  6. #include <stdlib.h>
  7.  
  8.  
  9. using namespace std;
  10.  
  11. void scl() {
  12.     system("cls");
  13. }
  14.  
  15. class AllColors {
  16.     public:
  17.         void ColorChoices() {
  18.             std::cout << ") Red" << endl;
  19.             std::cout << ") Green" << endl;
  20.             std::cout << ") Aqua" << endl;
  21.             std::cout << ") White" << endl;
  22.             std::cout << ") Default" << endl;
  23.             std::cout << ") Menu\n" << endl;
  24.         }
  25. };
  26.  
  27. int main() {
  28.     system("color d");
  29.     ShowWindow(GetConsoleWindow(), SW_MAXIMIZE);
  30.     SetConsoleTitle("Number Guess V1 Development Build");
  31.     int menu();
  32.     menu();
  33.  
  34.     return 0;
  35. }
  36.  
  37. int menu() {
  38.     string _menu_choice;
  39.    
  40.     std::cout << "Play Game" << endl;
  41.     std::cout << "Settings" << endl;
  42.     std::cout << "Exit\n" << endl;
  43.     std::cout << "> ";
  44.  
  45.     cin >> _menu_choice;
  46.  
  47.     if (_menu_choice == "PLAY" || _menu_choice == "Play" || _menu_choice == "play"
  48.         || _menu_choice == "GAME" || _menu_choice == "Game" || _menu_choice == "game") {
  49.         int playGame();
  50.         playGame();
  51.     }
  52.     else if (_menu_choice == "SETTINGS" || _menu_choice == "Settings" || _menu_choice == "settings") {
  53.         scl();
  54.         void settings();
  55.         settings();
  56.     }
  57.     else if (_menu_choice == "EXIT" || _menu_choice == "Exit" || _menu_choice == "exit"
  58.         || _menu_choice == "QUIT" || _menu_choice == "Quit" || _menu_choice == "quit") {
  59.         scl();
  60.         void quit();
  61.         quit();
  62.     }
  63.     else {
  64.         scl();
  65.         int menu();
  66.         menu();
  67.     }
  68.  
  69.     return 0;
  70. }
  71.  
  72. int playGame() {
  73.     scl();
  74.     string PlayGameOption;
  75.     std::cout << ") Easy" << endl;
  76.     std::cout << ") Medium" << endl;
  77.     std::cout << ") Hard" << endl;
  78.     std::cout << ") Menu\n" << endl;
  79.     std::cout << "> ";
  80.  
  81.     cin >> PlayGameOption;
  82.  
  83.     if (PlayGameOption == "EASY" || PlayGameOption == "Easy" || PlayGameOption == "easy") {
  84.         scl();
  85.         int playGameEasy();
  86.         playGameEasy();
  87.     }
  88.     else {
  89.         scl();
  90.         int playGame();
  91.         playGame();
  92.     }
  93.     return 0;
  94. }
  95.  
  96. int playGameEasy() {
  97.     int NumberEasy;
  98.     default_random_engine RandomEngineForEasyMode(time(NULL));
  99.     uniform_int_distribution<int> EasyMode(1, 20);
  100.     std::cout << "Enter 0 To Exit..." << endl;
  101.     std::cout << "--Press Any Key To Continue--" << endl;
  102.     system("pause >nul");
  103.     scl();
  104.  
  105.     Easy:
  106.     std::cout << "Guess the number from 1 to 20.\n" << endl;
  107.     cin >> NumberEasy;
  108.  
  109.     if (GetAsyncKeyState('0') & 0x8000) {
  110.         scl();
  111.         int playGame();
  112.         playGame();
  113.     }
  114.     if (NumberEasy == (EasyMode(RandomEngineForEasyMode))) {
  115.         scl();
  116.         std::cout << "Correct!" << endl;
  117.         std::cout << "--Press Any Key To Continue--" << endl;
  118.         system("pause >nul");
  119.         scl();
  120.         int playGame();
  121.         playGame();
  122.     }
  123.     else {
  124.         scl();
  125.         goto Easy;
  126.     }
  127.     return 0;
  128. }
  129.  
  130. void color() {
  131.     scl();
  132.     string ColorChoice;
  133.  
  134.     AllColors Colors;
  135.     Colors.ColorChoices();
  136.     std::cout << endl;
  137.     std::cout << "> ";
  138.  
  139.     cin >> ColorChoice;
  140.  
  141.     if (ColorChoice == "RED" || ColorChoice == "Red" || ColorChoice == "red") {
  142.         system("color c");
  143.         scl();
  144.         void settings();
  145.         settings();
  146.     }
  147.     else if (ColorChoice == "GREEN" || ColorChoice == "Green" || ColorChoice == "green") {
  148.         system("color a");
  149.         scl();
  150.         void settings();
  151.         settings();
  152.     }
  153.     else if (ColorChoice == "AQUA" || ColorChoice == "Aqua" || ColorChoice == "aqua") {
  154.         system("color b");
  155.         scl();
  156.         void settings();
  157.         settings();
  158.     }
  159.     else if (ColorChoice == "WHITE" || ColorChoice == "White" || ColorChoice == "white") {
  160.         system("color f");
  161.         scl();
  162.         void settings();
  163.         settings();
  164.     }
  165.     else if (ColorChoice == "DEFAULT" || ColorChoice == "Default" || ColorChoice == "default") {
  166.         system("color a");
  167.         scl();
  168.         void settings();
  169.         settings();
  170.     }
  171.     else if (ColorChoice == "BACK" || ColorChoice == "Back" || ColorChoice == "back") {
  172.         scl();
  173.         void settings();
  174.         settings();
  175.     }
  176.     else {
  177.         scl();
  178.         void color();
  179.         color();
  180.     }
  181. }
  182.  
  183. void settings() {
  184.     string _setting_choice;
  185.  
  186.     std::cout << ") Color" << endl;
  187.     std::cout << ") Menu\n" << endl;
  188.     std::cout << "> ";
  189.     cin >> _setting_choice;
  190.  
  191.     if (_setting_choice == "COLOR" || _setting_choice == "Color" || _setting_choice == "color") {
  192.         void color();
  193.         color();
  194.     }
  195.     else if (_setting_choice == "MENU" || _setting_choice == "Menu" || _setting_choice == "menu") {
  196.         scl();
  197.         int menu();
  198.         menu();
  199.     }
  200.     else {
  201.         scl();
  202.         void settings();
  203.         settings();
  204.     }
  205. }
  206.  
  207. void quit() {
  208.     string _quit_sure;
  209.  
  210.     std::cout << "Are you sure you want to quit? (Y\N)" << endl;
  211.     cin >> _quit_sure;
  212.  
  213.     if (_quit_sure == "Y" || _quit_sure == "y") {
  214.         exit(0);
  215.     }
  216.     else {
  217.         scl();
  218.         int menu();
  219.         menu();
  220.     }
  221. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement