#include #include #include #include #include int Rnum(int min,int max); void draw(); void control(); int s; int mine[20]; int t; int moves; char u = 2; char ground = 177; char v; int main() { srand(time(NULL)); moves = 0; s = 51; t = 1; while (t < 31) { mine[t] = Rnum(1,100); t++; } system("cls"); cout << "** ** ***** ** * **** ****\n"; cout << "* * * * * * * * ** ** \n"; cout << "* * * * * * ** * **\n"; cout << "* * * ***** * * **** ****\n"; cout << "\nBy Eric Marcarelli"; cout << "\n\nGoal: Get yourself across the deadly mine field alive."; cout << "\n\nMoves:"; cout << "\nUp - w"; cout << "\nDown - s"; cout << "\nLeft - a"; cout << "\nRight - d"; cout << "\n\nPress enter to continue..."; getch(); draw(); } int Rnum(int min,int max) { int value; value = min + rand() % max; return value; } void draw() { system("cls"); if ( 10 == s) cout << 'o'; else cout << ground; if ( 20 == s) cout << u; else cout << ground; if ( 30 == s) cout << u; else cout << ground; if ( 40 == s) cout << u; else cout << ground; if ( 50 == s) cout << u; else cout << ground; if ( 60 == s) cout << u; else cout << ground; if ( 70 == s) cout << u; else cout << ground; if ( 80 == s) cout << u; else cout << ground; if ( 90 == s) cout << u; else cout << ground; if ( 100 == s) cout << u; else cout << ground; cout << "\n"; if ( 9 == s) cout << u; else cout << ground; if ( 19 == s) cout << u; else cout << ground; if ( 29 == s) cout << u; else cout << ground; if ( 39 == s) cout << u; else cout << ground; if ( 49 == s) cout << u; else cout << ground; if ( 59 == s) cout << u; else cout << ground; if ( 69 == s) cout << u; else cout << ground; if ( 79 == s) cout << u; else cout << ground; if ( 89 == s) cout << u; else cout << ground; if ( 99 == s) cout << u; else cout << ground; cout << "\n"; if ( 8 == s) cout << u; else cout << ground; if ( 18 == s) cout << u; else cout << ground; if ( 28 == s) cout << u; else cout << ground; if ( 38 == s) cout << u; else cout << ground; if ( 48 == s) cout << u; else cout << ground; if ( 58 == s) cout << u; else cout << ground; if ( 68 == s) cout << u; else cout << ground; if ( 78 == s) cout << u; else cout << ground; if ( 88 == s) cout << u; else cout << ground; if ( 98 == s) cout << u; else cout << ground; cout << "\n"; if ( 7 == s) cout << u; else cout << ground; if ( 17 == s) cout << u; else cout << ground; if ( 27 == s) cout << u; else cout << ground; if ( 37 == s) cout << u; else cout << ground; if ( 47 == s) cout << u; else cout << ground; if ( 57 == s) cout << u; else cout << ground; if ( 67 == s) cout << u; else cout << ground; if ( 77 == s) cout << u; else cout << ground; if ( 87 == s) cout << u; else cout << ground; if ( 97 == s) cout << u; else cout << ground; cout << "\n"; if ( 6 == s) cout << u; else cout << ground; if ( 16 == s) cout << u; else cout << ground; if ( 26 == s) cout << u; else cout << ground; if ( 36 == s) cout << u; else cout << ground; if ( 46 == s) cout << u; else cout << ground; if ( 56 == s) cout << u; else cout << ground; if ( 66 == s) cout << u; else cout << ground; if ( 76 == s) cout << u; else cout << ground; if ( 86 == s) cout << u; else cout << ground; if ( 96 == s) cout << u; else cout << ground; cout << "\n"; if ( 5 == s) cout << u; else cout << ground; if ( 15 == s) cout << u; else cout << ground; if ( 25 == s) cout << u; else cout << ground; if ( 35 == s) cout << u; else cout << ground; if ( 45 == s) cout << u; else cout << ground; if ( 55 == s) cout << u; else cout << ground; if ( 65 == s) cout << u; else cout << ground; if ( 75 == s) cout << u; else cout << ground; if ( 85 == s) cout << u; else cout << ground; if ( 95 == s) cout << u; else cout << ground; cout << "\n"; if ( 4 == s) cout << u; else cout << ground; if ( 14 == s) cout << u; else cout << ground; if ( 24 == s) cout << u; else cout << ground; if ( 34 == s) cout << u; else cout << ground; if ( 44 == s) cout << u; else cout << ground; if ( 54 == s) cout << u; else cout << ground; if ( 64 == s) cout << u; else cout << ground; if ( 74 == s) cout << u; else cout << ground; if ( 84 == s) cout << u; else cout << ground; if ( 94 == s) cout << u; else cout << ground; cout << "\n"; if ( 3 == s) cout << u; else cout << ground; if ( 13 == s) cout << u; else cout << ground; if ( 23 == s) cout << u; else cout << ground; if ( 33 == s) cout << u; else cout << ground; if ( 43 == s) cout << u; else cout << ground; if ( 53 == s) cout << u; else cout << ground; if ( 63 == s) cout << u; else cout << ground; if ( 73 == s) cout << u; else cout << ground; if ( 83 == s) cout << u; else cout << ground; if ( 93 == s) cout << u; else cout << ground; cout << "\n"; if ( 2 == s) cout << u; else cout << ground; if ( 12 == s) cout << u; else cout << ground; if ( 22 == s) cout << u; else cout << ground; if ( 32 == s) cout << u; else cout << ground; if ( 42 == s) cout << u; else cout << ground; if ( 52 == s) cout << u; else cout << ground; if ( 62 == s) cout << u; else cout << ground; if ( 72 == s) cout << u; else cout << ground; if ( 82 == s) cout << u; else cout << ground; if ( 92 == s) cout << u; else cout << ground; cout << "\n"; if ( 1 == s) cout << u; else cout << ground; if ( 11 == s) cout << u; else cout << ground; if ( 21 == s) cout << u; else cout << ground; if ( 31 == s) cout << u; else cout << ground; if ( 41 == s) cout << u; else cout << ground; if ( 51 == s) cout << u; else cout << ground; if ( 61 == s) cout << u; else cout << ground; if ( 71 == s) cout << u; else cout << ground; if ( 81 == s) cout << u; else cout << ground; if ( 91 == s) cout << u; else cout << ground; control(); } void control() { if ((s == 10 ) || (s == 20 ) || (s == 30 ) || (s == 40 ) || (s == 50 ) || (s == 60 ) || (s == 70 ) || (s == 80 ) || (s == 90 ) || (s == 100 )) { if ((s != mine[1]) && (s != mine[2]) && (s != mine[3]) && (s != mine[4]) && (s != mine[5]) && (s != mine[6]) && (s != mine[7]) && (s != mine[8]) && (s != mine[9]) && (s != mine[10]) && (s != mine[11]) && (s != mine[12]) && (s != mine[13] ) && (s != mine[14] ) && (s != mine[15]) && (s != mine[16]) && (s != mine[17]) && (s != mine[18]) && (s != mine[19]) && (s != mine[20]) && (s != mine[21] ) && (s != mine[22] ) && (s != mine[23] ) && (s != mine[24] ) && (s != mine[25]) && (s != mine[26]) && (s != mine[27]) && (s != mine[28]) && (s != mine[29]) && (s != mine[30])) { cout << "\n\nYou crossed the mine field successfully in " << moves << " moves!"; cout << "\n\nPlay again? (y/n)> "; cin >> v; if (v == 'y') { getch(); main(); } else exit(0); } } if ((s == mine[1]) || (s == mine[2]) || (s == mine[3]) || (s == mine[4]) || (s == mine[5]) || (s == mine[6]) || (s == mine[7]) || (s == mine[8]) || (s == mine[9]) || (s == mine[10]) || (s == mine[11]) || (s == mine[12]) || (s == mine[13]) || (s == mine[14]) || (s == mine[15]) || (s == mine[16]) || (s == mine[17]) || (s == mine[18]) || (s == mine[19]) || (s == mine[20]) && (s == mine[21]) || (s == mine[22]) || (s == mine[23]) || (s == mine[24]) || (s == mine[25]) || (s == mine[26]) || (s == mine[27]) || (s == mine[28]) || (s == mine[29]) || (s == mine[30])) { cout << "\n\nBOOM!!! You hit a mine, you are dead!"; cout << "\n\nPlay again? (y/n)> "; cin >> v; if (v == 'y') { getch(); main(); } else exit(0); } cout << "\n"; v = getche(); moves++; if (v == 'w') s++; else if ((v == 's') && (s != 1) && (s != 11) && (s != 21) && (s != 31) && (s != 41) && (s != 51) && (s != 61) && (s != 71) && (s != 81) && (s != 91)) s--; else if ((v == 'a') && (s != 10) && (s != 9) && (s != 8) && (s != 7) && (s != 6) && (s != 5 ) && (s != 4 ) && (s != 3 ) && (s != 2 ) && (s != 1 )) s -= 10; else if ((v == 'd') && (s != 10 ) && (s != 99 ) && (s != 98 ) && (s != 97 ) && (s != 96 ) && (s != 95 ) && (s != 94 ) && (s != 93 ) && (s != 92 ) && (s != 91 )) s += 10; draw(); }