//Matthew Sachenik //Java //Period 1 #include #include #include #include #include using namespace std; //******************************** FUNCTIONS ***************************** void drawGrid(int x, int y); void showScreen(); void instuctions(); void pause(); void death(); void victory(); //The main part... int main() { showScreen(); char userLetter = 's'; int x = 0; int y = 0; cout << "X"; while (x != ' ') { userLetter = _getch(); if (userLetter == 'w') { x--; } else if (userLetter == 's') { x++; } else if (userLetter == 'a') { y--; } else if (userLetter == 'd') { y++; } else if (userLetter == 'p') { pause(); } //**************************** Boundary and victory *************** if (y == 25) //boundary { death(); pause(); return 0; } if (x == 25)//victory { victory(); pause(); return 0; } //**************************** Bombs (Organized by increasing x, then increasing y) ***************************** if (x == 3 && y == 3) { death(); pause(); return 0; } if (x == 3 && y == 9) { death(); pause(); return 0; } if (x == 3 && y == 17) { death(); pause(); return 0; } if (x == 4 && y == 4) { death(); pause(); return 0; } if (x == 4 && y == 10) { death(); pause(); return 0; } if (x == 4 && y == 13) { death(); pause(); return 0; } if (x == 5 && y == 1) { death(); pause(); return 0; } if (x == 5 && y == 12) { death(); pause(); return 0; } if (x == 5 && y == 20) { death(); pause(); return 0; } if (x == 6 && y == 0) { death(); pause(); return 0; } if (x == 8 && y == 4) { death(); pause(); return 0; } if (x == 8 && y == 5) { death(); pause(); return 0; } if (x == 8 && y == 7) { death(); pause(); return 0; } if (x == 8 && y == 24) { death(); pause(); return 0; } if (x == 11 && y == 11) { death(); pause(); return 0; } if (x == 12 && y == 10) { death(); pause(); return 0; } if (x == 14 && y == 3) { death(); pause(); return 0; } if (x == 14 && y == 15) { death(); pause(); return 0; } if (x == 18 && y == 12) { death(); pause(); return 0; } if (x == 19 && y == 2) { death(); pause(); return 0; } if (x == 20 && y == 19) { death(); pause(); return 0; } if (x == 20 && y == 20) { death(); pause(); return 0; } if (x == 20 && y == 21) { death(); pause(); return 0; } if (x == 23 && y == 6) { death(); pause(); return 0; } if (x == 23 && y == 16) { death(); pause(); return 0; } drawGrid(x, y); } system("pause"); return 0; } //****************************** First Screen ***************************** void showScreen() { system("color 20"); cout << " WELCOME TO MINEFIELD " << endl; cout << " GET TO THE BOTTOM WITHOUT BLOWING UP " << endl; cout << " ITS THAT SIMPLE " << endl; cout << " W,A,S,D TO MOVE, P TO PAUSE " << endl; cout << " PRESS ANY KEY TO START (YOU MAY HAVE TO SCROLL UP TO SEE X)" << endl; cout << " DO NOT STRAY TO FAR TO THE RIGHT!!! " << endl; cout << " GOOD LUCK!!! " << endl; } //****************************** Instructions (Not used... Moved instuctions to show screen.) **************************** void instructions() { cout << "The goal of the game is to collect all the vermon, /n once all the vermon are collected the game will end." << endl; } //****************************** Confirmation to continue ****************** void pause() { cout << "Press any key to continue... "; system("pause > nul"); } //***************************** Displays a loss *************************** void death() { cout << " YOUR DEAD!!! " << endl; } //***************************** Dusplays a victory ************************* void victory() { cout << " YOU WIN!!! " << endl; } //****************************** Draws the grid (On Mr. Minichs website) ************ void drawGrid(int x, int y) { system("cls"); for (int row = 0; row < 25; row++) { for (int col = 0; col < 25; col++) { if (row == x && col == y) { cout << "X"; } else { cout << " "; } } cout << endl; } }// end of drawGrid