| Brandalf (4) | |
|
Hey guys Iam in a bit of a pickle. My deadline is near and i have taken on too hard a project atm. I have got this minesweeper program i have started its not pretty bu it will do. I have basically got the menu system working and got the grid with the mines appearing but the mines are also appearing as i do not know how to cout a blank grid of stars. i have tryed for hours to get the program to cin values and check against the grid then reveal squares around it but i just cant do it. Please can anyone help me iam desperate for help. #include <iostream> #include <windows.h> #define _WIN32_WINNT 0x0500 #include <Windows.h> #include <stdlib.h> #include <stdio.h> #include <dos.h> #include <fstream> #include <sstream> #include <time.h> #include <string> #include <conio.h> using namespace std; void resize_windows (int height, int width); void resize_windows(); void Play_game(); void High_score(); void Help(); struct Score { int time[4]; char name[8]; }; int main () { resize_windows(600,600); //to resize the console window// int choice = 0; while (choice!= 5) { cout << "Manic Mines" << endl; cout <<"Press 2 to play game" << endl; cout <<"Press 3 for highscores" << endl; cout <<"Press 4 for help" << endl; cout <<"Press 5 to quit game" << endl; { cin >> choice; switch (choice) //Switch used to decide which menu option you will choose// { case 2: Play_game(); system ("CLS"); break; case 3: High_score(); system ("CLS"); break; case 4: Help(); system ("CLS"); break; } } } system("PAUSE"); return 0; } //***********ResizeWindowSubroutine*************************// void resize_windows (int height, int breadth) { HWND console = GetConsoleWindow(); RECT r; GetWindowRect (console, &r); MoveWindow(console, r.left, r.top, height, breadth, TRUE); } //**********************Play_gameSubroutine******************// void Play_game() { system ("CLS"); int minegrid [9][9] = {0};// grid to check values against int minecount = 0; int xnum; int ynum; int i; int j; int gridx; int gridy; //Randomseed// srand(time(NULL)); //** Used to put mines into the real grid **// do { xnum = rand () % 9 + 1; ynum = rand () % 9 + 1; if (minegrid[xnum][ynum]!=9) { minegrid[xnum][ynum] = 9; minecount ++; } } while (minecount < 10); //** Used to loop out the grid **// for ( i=0;i<9; i++) { for ( j=0;j<9; j++) { cout << " " << minegrid[i][j] << "\t"; } cout << "\n\n" << endl; } cout << endl; cout << endl; cout << "Input the grid co-ordinates you wish to choose" << endl; cin >> gridx; cin >> gridy; system("PAUSE"); } //************************High_scoreSubroutine****************// void High_score() { system ("CLS"); } //************************HelpSubroutine************************// void Help() { int goback; system ("CLS"); cout <<"How to play:" << endl; cout << endl; cout <<"Manic Mines is a game about finding mines in the game board." << endl; cout << endl; cout <<"Type in the co-ordinates of the square you wish to manipulate." << endl; cout << endl; cout <<"If you hit a mine then the game will end." << endl; cout << endl; cout <<"There will be 9 mines in the grid to find." << endl; cout << endl; cout <<"Be careful you can detonate a mine on your first turn." << endl; cout << endl; cout <<"When you select a square and it is not a mine," << endl; cout << endl; cout <<"Then the areas around it will be uncovered." << endl; cout << endl; cout <<"Your highscore will be based on time completed." << endl; cout << endl; cout <<"A score will not be saved if you fail to clear the board." << endl; cout << endl; cout <<"Good Luck!!!" << endl; cout << endl; cout <<"Happy Manic Mining..." << endl; cout << endl; system("PAUSE"); } | |
|
|
|
| cire (2354) | |||
Maybe dissecting the following will help.
| |||
|
|
|||