Project near deadline please help

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");
}

Maybe dissecting the following will help.

1
2
3
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <cstdlib>
#include <ctime>
#include <iostream>

struct Board
{
    int mineGrid[10][10] ;
    bool revealed[10][10] ;
};

void print(const Board& b)
{
    for ( unsigned i=0; i<10; ++i )
    {
        for ( unsigned j=0; j<10; ++j )
        {
            if ( b.revealed[i][j] )
                std::cout << b.mineGrid[i][j] ;
            else
                std::cout << '*' ;
        }
        std::cout << '\n' ;
    }
}

void zero(Board & b)
{
    for ( unsigned i=0; i<10; ++i )
        for ( unsigned j=0; j<10; ++j )
        {
            b.mineGrid[i][j] = 0 ;
            b.revealed[i][j] = false ;
        }
}

Board generateBoard()
{
    Board b ;
    zero(b) ;

    //** Used to put mines into the real grid **//

    unsigned minecount = 0 ;

    do
    {
        int xnum = rand () % 10;
        int ynum = rand () % 10;

        if ( b.mineGrid[xnum][ynum]!=9 )
        {
            b.mineGrid[xnum][ynum] = 9;

            minecount++;
        }

    } while (minecount < 10) ;

    return b ;
}

int main()
{
    srand(time(NULL));

    Board b = generateBoard() ;
    print(b) ;

    unsigned x, y ;
    while ( std::cout << "> " && std::cin >> x >> y )
    {
        b.revealed[x][y] = true ;
        print(b) ;
    }
}
Topic archived. No new replies allowed.