//Author Hector Rosario #include #include #include #include #include #include #include #include #include #include #include using namespace std; //my void functions void drawMaze(); void Maze1(); void cokeparty(); void room1(); void room2(); void drawRoom(); void help(); void newRoom(); void input(); void input2(); void input3(); void mainMenu(); void continueGame(); void save(); //My chars char guy = 1; //our hero int Currentroom = 1; string playerName; //my ints int move; //input for movement int x = 14; //starting x value on room one for main character int y = 8; //starting y value on room one for main character int m = 6;//starting x value on room two for main character int n = 0;//starting y value on room two for main character int g = 22;//starting x value on Mazeone for main character int h= 0;//starting y value on Mazeone for main character int life = 100; //Define default game board const int ROWS = 15; //constant row value for array const int COLUMNS = 22; // constant column value for array unsigned char room[ROWS][COLUMNS] = // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 {{'#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#','#'}, //0 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#','#'}, //1 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#','#'}, //2 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#','#'}, //3 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#','#'}, //4 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#','#'}, //5 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',' '}, //6 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#','#'}, //7 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#','#'}, //8 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#','#'}, //9 {'#', '#', '#', ' ', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#','#'}, //10 {'#', '#', '#', ' ', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#','#'}, //11 {'#', '#', '#', ' ', ' ', ' ', ' ', ' ', ' ', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#','#'}, //12 {'#', '#', '#', '#', '#', '#', '#', '#', ' ', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#','#'}, //13 {'#', '#', '#', '#', '#', '#', '#', '#', ' ', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#','#'}}; //14 unsigned char roomtwo[ROWS][COLUMNS] = // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 {{'#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#','#'}, //0 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#','#'}, //1 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#','#'}, //2 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#','#'}, //3 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#','#'}, //4 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ','#'}, //5 {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#','#'}, //6 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#','#'}, //7 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#','#'}, //8 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#','#'}, //9 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', '#', '#', '#', '#', '#', ' ', '#', '#', '#', '#', '#','#'}, //10 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', '#', '#', '#', '#', '#', ' ', '#', '#', '#', ' ', ' ','#'}, //11 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', '#', '#', '#', '#', '#', ' ', ' ', '#', '#', ' ', '#','#'}, //12 {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', '#', '#', '#', '#', '#', '#', ' ', ' ', ' ', ' ', '#','#'}, //13 {'#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#','#'}}; //14 const int Horizontal = 24; //constant row value for array const int Vertical = 40; // constant column value for array unsigned char mazeone[Horizontal][Vertical] = // 0 1 2 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 {{'-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'}, //0 {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //1 {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //2 {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //3 {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //4 {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //5 {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //6 {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //7 {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //8 {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //9 {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //10 {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //11 {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //12 {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //13 {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','/','-','-','-','-','-','-','-',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //14 {'|',' ',' ','/','-','-','-','-','-','-',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //15 {'|',' ',' ','|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|',' ','/','\\',' ','/','-','-',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //16 {'|',' ',' ','|',' ','/','-',' ','-','-','-','-','-','-','-','-','-','-','\\',' ','|',' ','|','|',' ','|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //17 {'|',' ',' ','|',' ','|','|',' ','|',' ',' ',' ',' ',' ',' ',' ',' ',' ','|',' ','|',' ','|','|',' ','|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //18 {'|',' ',' ','|',' ','|','|',' ','|',' ','-','\\','-','-',' ','-','-',' ','\\','-','/',' ','|','\\','-','-',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|',' ','|'}, //19 {'|',' ',' ','|',' ','|','|',' ','|',' ',' ','|',' ',' ',' ','|',' ',' ',' ',' ',' ',' ',' |',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|',' ','|',' ','|'}, //20 {'|','-','-','/',' ','|','|',' ','\\','-','-','/',' ','|',' ','|','-','-','-','-','-','-','/',' ','|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','\\','-','/',' ','|'}, //21 {' ',' ',' ',' ',' ','/','\\',' ',' ',' ',' ',' ',' ','|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'}, //22 {'|','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'}}; //23 int loop = 0; int main() { HANDLE hStdout; hStdout = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(hStdout, BACKGROUND_GREEN); //Makes welcome text green. cout << "Welcome!"<> menuSelect; switch(menuSelect) { case 's': case 'S': system("cls"); cout << "Please enter your name: " << endl; //get player info to start new game cin >> playerName; menuLoop = 0; break; case 'c': case 'C': continueGame(); // goes to void continue if(Currentroom == 1) { room[x][y] = guy; drawRoom(); room1(); } else if(Currentroom == 2) { roomtwo[m][n] = guy; newRoom(); room2(); } else if(Currentroom == 3) { mazeone[g][h] = guy; drawMaze(); Maze1(); } menuLoop = 0; break; menuLoop = 0; break; case 'q': case 'Q': //quit loop = 0; loop = 0; break; case 'h': case 'H': //display help function help(); break; default: system("cls"); cout << "Invalid Selection!" << endl; system("pause"); break; } } } void save() { //save player name, life, and current coordinates on the board ofstream saveGame; saveGame.open("save.txt"); saveGame << playerName << " " << life << " " << x << " " << y << " " << m << " " << n << " " << g << " " << h << " " << Currentroom << endl; saveGame.close(); } void continueGame()//I think my problem is here... { //open save file for previous matrix position and health //if (guy == room[x][y]) // { ifstream continueData; continueData.open("save.txt"); continueData >> playerName >> life >> x >> y >> m >> n >> g >> h >> Currentroom; continueData.close(); // } } /***** Movement And Input Function *****/ void input() { //Get user input to determine new coordinates move = _getche(); switch(move) { case 'a': case 'A': y--; if(room[x][y] == ' ')//collision detection and life detection { room[x][y] = guy; //draw new position room[x][y + 1] = ' '; //clear old position break; } else y++; break; case 'd': case 'D': y++; if(room[x][y] == ' ') { room[x][y] = guy; room[x][y - 1] = ' '; break; } else y--; break; case 's': case 'S': x++; if(room[x][y] == ' ') { room[x][y] = guy; room[x - 1][y] = ' '; break; } else x--; break; case 'w': case 'W': x--; if(room[x][y] == ' ') { room[x][y] = guy; room[x + 1][y] = ' '; break; } else x++; break; case 'z': case 'Z': { save(); } system("cls"); cout << "Game Saved\n\n" << endl; system("pause"); break; case 'h': case 'H': //Invoke help function help(); break; case 'q': case 'Q': //Assign new value to loop variable and exit the game loop = 1; break; } } void input2() { { //Get user input to determine new coordinates move = _getche(); switch(move) { case 'a': case 'A': n--; if(roomtwo[m][n] == ' ')//collision detection and life detection { roomtwo[m][n] = guy; //draw new position roomtwo[m][n + 1] = ' '; //clear old position break; } else n++; break; case 'd': case 'D': n++; if(roomtwo[m][n] == ' ') { roomtwo[m][n] = guy; roomtwo[m][n - 1] = ' '; break; } else n--; break; case 's': case 'S': m++; if(roomtwo[m][n] == ' ') { roomtwo[m][n] = guy; roomtwo[m - 1][n] = ' '; break; } else m--; break; case 'w': case 'W': m--; if(roomtwo[m][n] == ' ') { roomtwo[m][n] = guy; roomtwo[m + 1][n] = ' '; break; } else m++; break; case 'z': case 'Z': { //save player name, life, and current coordinates on the board save(); } system("cls"); cout << "Game Saved\n\n" << endl; system("pause"); break; case 'h': case 'H': //Invoke help function help(); break; case 'q': case 'Q': //Assign new value to loop variable and exit the game loop = 1; break; } } } void input3() { { //Get user input to determine new coordinates move = _getche(); switch(move) { case 'a': case 'A': h--; if(mazeone[g][h] == ' ')//collision detection and life detection { mazeone[g][h] = guy; //draw new position mazeone[g][h + 1] = ' '; //clear old position break; } else h++; break; case 'd': case 'D': h++; if(mazeone[g][h] == ' ') { mazeone[g][h] = guy; mazeone[g][h - 1] = ' '; break; } else h--; break; case 's': case 'S': g++; if(mazeone[g][h] == ' ') { mazeone[g][h] = guy; mazeone[g - 1][h] = ' '; break; } else g--; break; case 'w': case 'W': g--; if(mazeone[g][h] == ' ') { mazeone[g][h] = guy; mazeone[g + 1][h] = ' '; break; } else g++; break; case 'z': case 'Z': { save(); } system("cls"); cout << "Game Saved\n\n" << endl; system("pause"); break; case 'h': case 'H': //Invoke help function help(); break; case 'q': case 'Q': //Assign new value to loop variable and exit the game loop = 1; break; } } } void room1() { int x = 5; //starting x value on game board for main character int y = 21; while(loop == 0) { room[x][y]; //Starting point for main character drawRoom(); input(); if (room[6][21]!= ' ') { Currentroom = 2; room2();}//returns me to room 2 } } void room2() { int m = 6; //starting x value on game board for main character int n = 0; system("cls"); cout << "\n" << guy << " On to the coke PARTYYYYYY!!!!!!!! " <