Advertisement
Guest User

Simon Game cont. 2

a guest
Nov 13th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. #include <cmath>
  5. #include <string>
  6. using namespace std;
  7.  
  8. void ColorBoard(int color) {        //input for display will be an array, translating into a number 0-3
  9.     static_cast<char>(color);
  10.     if (color == 'G') {
  11.         cout << "___________________________________" << endl;
  12.         cout << "_                _                _" << endl;
  13.         cout << "_     GGGG       _                _" << endl;
  14.         cout << "_    G    G      _                _" << endl;
  15.         cout << "_   G            _                _" << endl;
  16.         cout << "_   G   GGGG     _                _" << endl;
  17.         cout << "_   G     GG     _                _" << endl;
  18.         cout << "_    G     G     _                _" << endl;
  19.         cout << "_      GGGG      _                _" << endl;
  20.         cout << "_                _                _" << endl;
  21.         cout << "___________________________________" << endl;
  22.         cout << "_                _                _" << endl;
  23.         cout << "_                _                _" << endl;
  24.         cout << "_                _                _" << endl;
  25.         cout << "_                _                _" << endl;
  26.         cout << "_                _                _" << endl;
  27.         cout << "_                _                _" << endl;
  28.         cout << "_                _                _" << endl;
  29.         cout << "_                _                _" << endl;
  30.         cout << "_                _                _" << endl;
  31.         cout << "___________________________________" << endl;
  32.     }
  33.     else if (color == 'R') {
  34.         cout << "___________________________________" << endl;
  35.         cout << "_                _                _" << endl;
  36.         cout << "_                _     RRRR       _" << endl;
  37.         cout << "_                _     R   R      _" << endl;
  38.         cout << "_                _     R   R      _" << endl;
  39.         cout << "_                _     RRRR       _" << endl;
  40.         cout << "_                _     RR         _" << endl;
  41.         cout << "_                _     R R        _" << endl;
  42.         cout << "_                _     R  R       _" << endl;
  43.         cout << "_                _                _" << endl;
  44.         cout << "___________________________________" << endl;
  45.         cout << "_                _                _" << endl;
  46.         cout << "_                _                _" << endl;
  47.         cout << "_                _                _" << endl;
  48.         cout << "_                _                _" << endl;
  49.         cout << "_                _                _" << endl;
  50.         cout << "_                _                _" << endl;
  51.         cout << "_                _                _" << endl;
  52.         cout << "_                _                _" << endl;
  53.         cout << "_                _                _" << endl;
  54.         cout << "___________________________________" << endl;
  55.     }
  56.     else if (color == 'Y') {
  57.         cout << "___________________________________" << endl;
  58.         cout << "_                _                _" << endl;
  59.         cout << "_                _                _" << endl;
  60.         cout << "_                _                _" << endl;
  61.         cout << "_                _                _" << endl;
  62.         cout << "_                _                _" << endl;
  63.         cout << "_                _                _" << endl;
  64.         cout << "_                _                _" << endl;
  65.         cout << "_                _                _" << endl;
  66.         cout << "_                _                _" << endl;
  67.         cout << "___________________________________" << endl;
  68.         cout << "_                _                _" << endl;
  69.         cout << "_   Y       Y    _                _" << endl;
  70.         cout << "_    Y     Y     _                _" << endl;
  71.         cout << "_     Y   Y      _                _" << endl;
  72.         cout << "_      YYY       _                _" << endl;
  73.         cout << "_       Y        _                _" << endl;
  74.         cout << "_       Y        _                _" << endl;
  75.         cout << "_       Y        _                _" << endl;
  76.         cout << "_                _                _" << endl;
  77.         cout << "___________________________________" << endl;
  78.     }
  79.     else if (color == 'B') {
  80.         cout << "___________________________________" << endl;
  81.         cout << "_                _                _" << endl;
  82.         cout << "_                _                _" << endl;
  83.         cout << "_                _                _" << endl;
  84.         cout << "_                _                _" << endl;
  85.         cout << "_                _                _" << endl;
  86.         cout << "_                _                _" << endl;
  87.         cout << "_                _                _" << endl;
  88.         cout << "_                _                _" << endl;
  89.         cout << "_                _                _" << endl;
  90.         cout << "___________________________________" << endl;
  91.         cout << "_                _                _" << endl;
  92.         cout << "_                _     BBBB       _" << endl;
  93.         cout << "_                _     B   B      _" << endl;
  94.         cout << "_                _     B   B      _" << endl;
  95.         cout << "_                _     BBBB       _" << endl;
  96.         cout << "_                _     B   B      _" << endl;
  97.         cout << "_                _     B   B      _" << endl;
  98.         cout << "_                _     BBBB       _" << endl;
  99.         cout << "_                _                _" << endl;
  100.         cout << "___________________________________" << endl;
  101.     }
  102. }
  103.  
  104. //next part is used between each display and at the end, just a blank board cout statement
  105.  
  106. void BlankBoard () {
  107.     cout << "___________________________________" << endl;
  108.     cout << "_                _                _" << endl;
  109.     cout << "_                _                _" << endl;
  110.     cout << "_                _                _" << endl;
  111.     cout << "_                _                _" << endl;
  112.     cout << "_                _                _" << endl;
  113.     cout << "_                _                _" << endl;
  114.     cout << "_                _                _" << endl;
  115.     cout << "_                _                _" << endl;
  116.     cout << "_                _                _" << endl;
  117.     cout << "___________________________________" << endl;
  118.     cout << "_                _                _" << endl;
  119.     cout << "_                _                _" << endl;
  120.     cout << "_                _                _" << endl;
  121.     cout << "_                _                _" << endl;
  122.     cout << "_                _                _" << endl;
  123.     cout << "_                _                _" << endl;
  124.     cout << "_                _                _" << endl;
  125.     cout << "_                _                _" << endl;
  126.     cout << "_                _                _" << endl;
  127.     cout << "___________________________________" << endl;
  128. }
  129.  
  130. int main()
  131. {
  132.     string userInput = "";
  133.     string sequence = "";
  134.     int numRound = 1;
  135.     int color[4] = {'G', 'R', 'Y', 'B'};
  136.     bool status;
  137.     int currentColor;
  138.     int temp;
  139.  
  140.     srand(time(NULL));
  141.    
  142. //colors: 0=G 1=R 2=Y 3=B
  143.  
  144.     do {
  145.     sequence += static_cast<int>(color[rand() % 3]);
  146.     currentColor = color[rand() % 3];
  147.    
  148.     for (int i = 1; i <= numRound; ++i) {           //initial cout statements
  149.         ColorBoard(currentColor);
  150.         BlankBoard();
  151.         temp = i;
  152.     }
  153.     numRound = temp;
  154.     cout << "Please enter in the character sequence you observed on the screen" << endl;
  155.     cin >> userInput;
  156.     //took off ++numRound
  157.         if(sequence != userInput) {
  158.             cout << "You made it to round " << numRound - 1 << endl;
  159.             cout << "Game Over!";
  160.             status = false;
  161.         }
  162.     }while(status == true);
  163.  
  164.     return 0;
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement