Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.23 KB | None | 0 0
  1. /******************************************************************************************
  2. SIMON
  3. Team Mystic
  4. Ali Hajirahim, Nathan Urquhart, Stanly Gomez
  5. ECGR 2103 002
  6. 11/10/2019
  7.  
  8. *******************************************************************************************/
  9. #include <iostream>
  10. #include <ctime>
  11. #include <cstdlib>
  12. #include <string>
  13. #include <unistd.h>
  14. using namespace std;
  15.  
  16. void ColorBoard(char color) { //input for display will be an array, translating into a number 0-3
  17. if (color == 'G') {
  18. cout << "___________________________________" << endl;
  19. cout << "_ _ _" << endl;
  20. cout << "_ GGGG _ _" << endl;
  21. cout << "_ G G _ _" << endl;
  22. cout << "_ G _ _" << endl;
  23. cout << "_ G GGGG _ _" << endl;
  24. cout << "_ G GG _ _" << endl;
  25. cout << "_ G G _ _" << endl;
  26. cout << "_ GGGG _ _" << endl;
  27. cout << "_ _ _" << endl;
  28. cout << "___________________________________" << endl;
  29. cout << "_ _ _" << endl;
  30. cout << "_ _ _" << endl;
  31. cout << "_ _ _" << endl;
  32. cout << "_ _ _" << endl;
  33. cout << "_ _ _" << endl;
  34. cout << "_ _ _" << endl;
  35. cout << "_ _ _" << endl;
  36. cout << "_ _ _" << endl;
  37. cout << "_ _ _" << endl;
  38. cout << "___________________________________" << endl;
  39. }
  40. else if (color == 'R') {
  41. cout << "___________________________________" << endl;
  42. cout << "_ _ _" << endl;
  43. cout << "_ _ RRRR _" << endl;
  44. cout << "_ _ R R _" << endl;
  45. cout << "_ _ R R _" << endl;
  46. cout << "_ _ RRRR _" << endl;
  47. cout << "_ _ RR _" << endl;
  48. cout << "_ _ R R _" << endl;
  49. cout << "_ _ R R _" << endl;
  50. cout << "_ _ _" << endl;
  51. cout << "___________________________________" << endl;
  52. cout << "_ _ _" << endl;
  53. cout << "_ _ _" << endl;
  54. cout << "_ _ _" << endl;
  55. cout << "_ _ _" << endl;
  56. cout << "_ _ _" << endl;
  57. cout << "_ _ _" << endl;
  58. cout << "_ _ _" << endl;
  59. cout << "_ _ _" << endl;
  60. cout << "_ _ _" << endl;
  61. cout << "___________________________________" << endl;
  62. }
  63. else if (color == 'Y') {
  64. cout << "___________________________________" << endl;
  65. cout << "_ _ _" << endl;
  66. cout << "_ _ _" << endl;
  67. cout << "_ _ _" << endl;
  68. cout << "_ _ _" << endl;
  69. cout << "_ _ _" << endl;
  70. cout << "_ _ _" << endl;
  71. cout << "_ _ _" << endl;
  72. cout << "_ _ _" << endl;
  73. cout << "_ _ _" << endl;
  74. cout << "___________________________________" << endl;
  75. cout << "_ _ _" << endl;
  76. cout << "_ Y Y _ _" << endl;
  77. cout << "_ Y Y _ _" << endl;
  78. cout << "_ Y Y _ _" << endl;
  79. cout << "_ YYY _ _" << endl;
  80. cout << "_ Y _ _" << endl;
  81. cout << "_ Y _ _" << endl;
  82. cout << "_ Y _ _" << endl;
  83. cout << "_ _ _" << endl;
  84. cout << "___________________________________" << endl;
  85. }
  86. else if (color == 'B') {
  87. cout << "___________________________________" << endl;
  88. cout << "_ _ _" << endl;
  89. cout << "_ _ _" << endl;
  90. cout << "_ _ _" << endl;
  91. cout << "_ _ _" << endl;
  92. cout << "_ _ _" << endl;
  93. cout << "_ _ _" << endl;
  94. cout << "_ _ _" << endl;
  95. cout << "_ _ _" << endl;
  96. cout << "_ _ _" << endl;
  97. cout << "___________________________________" << endl;
  98. cout << "_ _ _" << endl;
  99. cout << "_ _ BBBB _" << endl;
  100. cout << "_ _ B B _" << endl;
  101. cout << "_ _ B B _" << endl;
  102. cout << "_ _ BBBB _" << endl;
  103. cout << "_ _ B B _" << endl;
  104. cout << "_ _ B B _" << endl;
  105. cout << "_ _ BBBB _" << endl;
  106. cout << "_ _ _" << endl;
  107. cout << "___________________________________" << endl;
  108. }
  109. }
  110.  
  111. //next part is used between each display and at the end, just a blank board cout statement
  112.  
  113. void BlankBoard () {
  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. cout << "_ _ _" << endl;
  129. cout << "_ _ _" << endl;
  130. cout << "_ _ _" << endl;
  131. cout << "_ _ _" << endl;
  132. cout << "_ _ _" << endl;
  133. cout << "_ _ _" << endl;
  134. cout << "___________________________________" << endl;
  135. }
  136.  
  137. int main()
  138. {
  139. char userInput[50];
  140. char sequence[50];
  141. string fullSequence = "";
  142. string usrInput = "";
  143. int numRound = 1;
  144. char color[4] = {'G', 'R', 'Y', 'B'};
  145. bool status = true;
  146. int currentColor;
  147. int temp;
  148. char userDiff;
  149.  
  150. srand(time(NULL)); //colors: 0=G 1=R 2=Y 3=B
  151. for(int i = 0; i <= 50; ++i){
  152. sequence[i] = (color[rand() % 3]);
  153. }
  154.  
  155. cout << "Please enter your level of difficulty:\n'e' for easy\n'm' for medium\n'h' for hard\nIf input does not match a difficulty, difficulty will be set to hard.\n";
  156. cin >> userDiff;
  157. system("tput clear");
  158.  
  159. do {
  160. for (int i = 1; i <= numRound; ++i) { //initial cout statements
  161. if (userDiff == 'e') {
  162. system("tput clear");
  163. ColorBoard(sequence[i]);
  164. usleep(1000000);
  165. system("tput clear");
  166. BlankBoard();
  167. usleep(1000000);
  168. }
  169. else if (userDiff == 'm') {
  170. system("tput clear");
  171. ColorBoard(sequence[i]);
  172. usleep(500000);
  173. system("tput clear");
  174. BlankBoard();
  175. usleep(500000);
  176. }
  177. else {
  178. system("tput clear");
  179. ColorBoard(sequence[i]);
  180. usleep(250000);
  181. system("tput clear");
  182. BlankBoard();
  183. usleep(250000);
  184. }
  185. temp = i;
  186. }
  187. numRound = temp;
  188. cout << "Please enter in the character sequence you observed on the screen" << endl;
  189. cin >> usrInput;
  190. //took off ++numRound
  191. fullSequence += sequence[temp];
  192. if(fullSequence != usrInput) {
  193. cout << "Sorry the combination was not correct your final score is " << numRound - 1 << endl;
  194. cout << "Game Over!";
  195. status = false;
  196. }
  197. ++numRound;
  198. } while (status == true);
  199. return 0;
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement