#include #include #include using namespace std; char grid[50]; int stage = 1; string command; int started=0; int newCommand=0; string description; int currentSquare; int movingSquare=0; char direction; string endGame; int checkSquare (int space) { if (grid[space]=='*') { cout << endl << "MESSAGE: You found a key! All the doors have been unlocked!" << endl; for (int i=0; i42 || space%7==1) { stage = stage+1; } } int moveSquare(char dir) { if (dir=='r') { if ((grid[movingSquare+1]==' '||grid[movingSquare+1]=='*') && grid[movingSquare]%7!=0) { grid[movingSquare]=' '; grid[movingSquare+1]='X'; movingSquare=movingSquare+1; } } else if (dir=='l' && grid[movingSquare]%7!=1) { if (grid[movingSquare-1]==' '||grid[movingSquare-1]=='*') { grid[movingSquare]=' '; grid[movingSquare-1]='X'; movingSquare=movingSquare-1; } } else if (dir=='u' && movingSquare>7) { if (grid[movingSquare-7]==' '||grid[movingSquare-7]=='*') { grid[movingSquare]=' '; grid[movingSquare-7]='X'; movingSquare=movingSquare-7; } } else if (dir=='d') { if ((grid[movingSquare+7]==' '||grid[movingSquare+7]=='*') && movingSquare<43) { grid[movingSquare]=' '; grid[movingSquare+7]='X'; movingSquare=movingSquare+7; } } } int getDescription () { cout << description << endl << endl; } int showGrid () { cout << endl << endl; for (int i=0; i> command; if (command=="start") { if (started==0) { started=1; newCommand=1; } else { cout << endl << "You've already started!" << endl << endl; } } else if (started==1) { if (command=="info") { getDescription(); newCommand=1; } else if (command=="look") { showGrid(); newCommand=1; } else if (command=="u") { if (grid[currentSquare-7]!='X' && grid[currentSquare-7]!='-') { grid[currentSquare]=' '; if (stage>1) { grid[currentSquare]='X'; } checkSquare(currentSquare-7); grid[currentSquare-7]='O'; currentSquare = currentSquare-7; if (stage>4) { moveSquare(direction); } showGrid(); newCommand=1; } else { cout << endl << "I'm afraid there's something in your way. If you\nare really stuck, you can reset the stage by typing \"reset\"." << endl; newCommand=1; } } else if (command=="d") { if (grid[currentSquare+7]!='X' && grid[currentSquare+7]!='-') { grid[currentSquare]=' '; if (stage>1) { grid[currentSquare]='X'; } checkSquare(currentSquare+7); grid[currentSquare+7]='O'; currentSquare = currentSquare+7; if (stage>4) { moveSquare(direction); } showGrid(); newCommand=1; } else { cout << endl << "I'm afraid there's something in your way." << endl; newCommand=1; } } else if (command=="l") { if (grid[currentSquare-1]!='X' && grid[currentSquare-1]!='|') { grid[currentSquare]=' '; if (stage>1) { grid[currentSquare]='X'; } checkSquare(currentSquare-1); grid[currentSquare-1]='O'; currentSquare = currentSquare-1; if (stage>4) { moveSquare(direction); } showGrid(); newCommand=1; } else { cout << "I'm afraid there's something in your way." << endl; newCommand=1; } } else if (command=="r") { if (grid[currentSquare+1]!='X' && grid[currentSquare+1]!='|') { grid[currentSquare]=' '; if (stage>1) { grid[currentSquare]='X'; } checkSquare(currentSquare+1); grid[currentSquare+1]='O'; currentSquare = currentSquare+1; if (stage>4) { moveSquare(direction); } showGrid(); newCommand=1; } else { cout << endl << "I'm afraid there's something in your way." << endl; newCommand=1; } } else if (command=="skip") { if (stage>4) { moveSquare(direction); } showGrid(); newCommand=1; } else if (command=="reset") { setLevel(stage); showGrid(); newCommand=1; } else if (command == "help") { getHelp(); newCommand=1; } else { cout << endl << "Say what now?" << endl; newCommand=1; } } else { cout << endl << "Say what now?" << endl; newCommand=1; } cout << endl; } int main () { cout << ".:: MAZE RUNNER ::." << endl; cout << "Version 1.1" << endl << endl; getHelp(); cout << "To start, type \"start\" and hit enter!" << endl << endl; setLevel(stage); while (started==0) { while (newCommand==0) { inputCommand(); } newCommand=0; } cout << endl << endl << endl << endl; showGrid(); cout << endl; getDescription(); cout << endl; newCommand=0; while (stage==1) { while (newCommand==0) { cout << endl; inputCommand(); } newCommand=0; } cout << "You have made it out of the first room, but wwill you make it any farther?" << endl; setLevel(stage); cout << endl; getDescription(); cout << endl; newCommand=0; showGrid(); while (stage==2) { while (newCommand==0) { cout << endl; inputCommand(); } newCommand=0; } cout << "You have completed level two, but now it only gets harder!" << endl; setLevel(stage); cout << endl; getDescription(); cout << endl; newCommand=0; showGrid(); while (stage==3) { while (newCommand==0) { cout << endl; inputCommand(); } newCommand=0; } cout << "You made it out of a tough one, but there are still more levels!" << endl; setLevel(stage); cout << endl; getDescription(); cout << endl; newCommand=0; showGrid(); while (stage==4) { while (newCommand==0) { cout << endl; inputCommand(); } newCommand=0; } cout << "You finished that level, but be warned, the next ones are tricky!" << endl; setLevel(stage); cout << endl; getDescription(); cout << endl; newCommand=0; showGrid(); while (stage==5) { while (newCommand==0) { cout << endl; inputCommand(); } newCommand=0; } cout << "You may have figured out the moving blocks but they are not done yet!" << endl; setLevel(stage); cout << endl; getDescription(); cout << endl; newCommand=0; showGrid(); while (stage==6) { while (newCommand==0) { cout << endl; inputCommand(); } newCommand=0; } cout << "Good luck getting out of this one!" << endl; setLevel(stage); cout << endl; getDescription(); cout << endl; newCommand=0; showGrid(); while (stage==7) { while (newCommand==0) { cout << endl; inputCommand(); } newCommand=0; } cout << "Okay, that was hard, but there's more to come!" << endl; setLevel(stage); cout << endl; getDescription(); cout << endl; newCommand=0; showGrid(); while (stage==8) { while (newCommand==0) { cout << endl; inputCommand(); } newCommand=0; } cout << "Nice attempt. You can't pass this next one." << endl; setLevel(stage); cout << endl; getDescription(); cout << endl; newCommand=0; showGrid(); while (stage==9) { while (newCommand==0) { cout << endl; inputCommand(); } newCommand=0; } cout << "Here we go, this one is hard." << endl; setLevel(stage); cout << endl; getDescription(); cout << endl; newCommand=0; showGrid(); while (stage==10) { while (newCommand==0) { cout << endl; inputCommand(); } newCommand=0; } cout << "::: ::: :::::::: ::: ::: ::: ::: ::::::::::: :::: :::" << endl << ":+: :+: :+: :+: :+: :+: :+: :+: :+: :+:+: :+:" << endl << " +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ :+:+:+ +:+" << endl << " +#++: +#+ +:+ +#+ +:+ +#+ +:+ +#+ +#+ +#+ +:+ +#+" << endl << " +#+ +#+ +#+ +#+ +#+ +#+ +#+#+ +#+ +#+ +#+ +#+#+#" << endl << " #+# #+# #+# #+# #+# #+#+# #+#+# #+# #+# #+#+#" << endl << " ### ######## ######## ### ### ########### ### ####" << endl << " Level design by Sari and David. Programmed by David in C++." << endl; cin >> endGame; return 0; }