Battleship grid

hello, making battleship however i am not sure how to start with the grid. How would i start making the grid? could u give me some links to anything that helps or explain to me below, thanks. I am trying to make this in the console.
Not trying to come off rude or anything, but if you cannot manage something as simple as a 2D grid, then you probably shouldn't bother making a battleship game. Nonetheless, here's an example of how you would go about making a grid:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
int playerGameBoard[10][10];
const int ROWS = 10;
const int COLUMNS = 10;

//Init the game board.
for (int i = 0; i < ROWS; ++i)
{
for (int j = 0; j < COLUMNS; ++j)
{
playerGameBoard[i][j] = EMPTY;
}
}

//Display the game board.
for (int i = 0; i < ROWS; ++i)
{
for (int j = 0; j < COLUMNS; ++j)
{
cout << playerGameBoard[i][j];
}
cout << endl;
}



Last edited on
Search this forum for "battleship".
You will find lots of examples.
Topic archived. No new replies allowed.