Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************************
- SIMON
- Team Mystic
- Ali Hajirahim, Nathan Urquhart, Stanly Gomes
- ECGR 2103 002
- 11/10/2019
- *******************************************************************************************/
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- #include <string>
- #include <unistd.h>
- using namespace std;
- void ColorBoard(char color) { //input for display will be an array, translating into a number 0-3
- if (color == 'G') {
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ GGGG _ _" << endl;
- cout << "_ G G _ _" << endl;
- cout << "_ G _ _" << endl;
- cout << "_ G GGGG _ _" << endl;
- cout << "_ G GG _ _" << endl;
- cout << "_ G G _ _" << endl;
- cout << "_ GGGG _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- }
- else if (color == 'R') {
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ RRRR _" << endl;
- cout << "_ _ R R _" << endl;
- cout << "_ _ R R _" << endl;
- cout << "_ _ RRRR _" << endl;
- cout << "_ _ RR _" << endl;
- cout << "_ _ R R _" << endl;
- cout << "_ _ R R _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- }
- else if (color == 'Y') {
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ Y Y _ _" << endl;
- cout << "_ Y Y _ _" << endl;
- cout << "_ Y Y _ _" << endl;
- cout << "_ YYY _ _" << endl;
- cout << "_ Y _ _" << endl;
- cout << "_ Y _ _" << endl;
- cout << "_ Y _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- }
- else if (color == 'B') {
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ BBBB _" << endl;
- cout << "_ _ B B _" << endl;
- cout << "_ _ B B _" << endl;
- cout << "_ _ BBBB _" << endl;
- cout << "_ _ B B _" << endl;
- cout << "_ _ B B _" << endl;
- cout << "_ _ BBBB _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- }
- }
- //next part is used between each display and at the end, just a blank board cout statement
- void BlankBoard () {
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- }
- int main()
- {
- char userInput[50]; //declaring variables
- char sequence[50];
- string fullSequence = "";
- string usrInput = "";
- int numRound = 1;
- char color[4] = {'G', 'R', 'Y', 'B'};
- bool status = true;
- int currentColor;
- int temp;
- char userDiff;
- srand(time(NULL)); //colors: 0=G 1=R 2=Y 3=B
- for(int i = 0; i <= 50; ++i){
- sequence[i] = (color[rand() % 4]); //loop to fill in the array "sequence" with random numbers representing colors
- }
- 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";
- cin >> userDiff;
- system("tput clear");
- do {
- for (int i = 1; i <= numRound; ++i) { //showing board, added delays
- if (userDiff == 'e') { //different if else statements for difficulty delays
- system("tput clear"); //clears the output boards
- ColorBoard(sequence[i]);
- usleep(1000000); //easy difficulty
- system("tput clear");
- BlankBoard();
- usleep(1000000);
- }
- else if (userDiff == 'm') {
- system("tput clear");
- ColorBoard(sequence[i]);
- usleep(500000); //medium difficulty
- system("tput clear");
- BlankBoard();
- usleep(500000);
- }
- else {
- system("tput clear");
- ColorBoard(sequence[i]);
- usleep(250000); //hard difficulty
- system("tput clear");
- BlankBoard();
- usleep(250000);
- }
- temp = i; //sets variable "temp" to current round
- }
- numRound = temp; //variable to temporarily store the current round
- cout << "Please enter in the character sequence you observed on the screen" << endl;
- cin >> usrInput;
- //took off ++numRound
- fullSequence += sequence[temp];
- if(fullSequence != usrInput) {
- cout << "Sorry the combination was not correct your final score is " << numRound - 1 << endl;
- cout << "Game Over!";
- status = false; //sets status to false, ending program
- }
- ++numRound
- } while (status == true);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement