Ok so I am making a Battleship game and I started to make the actual board for it. This is what I have so far:
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <conio.h>
using namespace std;
int global_ship_count = 10;
int gameOver;
int currentPlayer;
int error;
int input;
int inputX;
int inputY;
int attack;
int attackX;
int attackY;
int printY;
int printX;
string newLine;
int hitCount;
void CreateMap1(string mapArray1[10][10])
{
for (int row = 0; row < 10; row++)
{
cout << "" << endl;
for (int col = 0; col < 10; col++)
{
cout << mapArray1[row][col] << " ";
}
cout << endl;
}
}
int main()
{
const int row = 10;
const int col = 10;
string Board[row][col];
Board[0][0] = "0";
Board[0][1] = "1";
Board[0][2] = "2";
Board[0][3] = "3";
Board[0][4] = "4";
Board[0][5] = "5";
Board[0][6] = "6";
Board[0][7] = "7";
Board[0][8] = "8";
Board[0][9] = "9";
Board[0][0] = "0";
Board[1][0] = "1";
Board[2][0] = "2";
Board[3][0] = "3";
Board[4][0] = "4";
Board[5][0] = "5";
Board[6][0] = "6";
Board[7][0] = "7";
Board[8][0] = "8";
Board[9][0] = "9";
CreateMap1(Board);
system("Pause");
return(0);
}
There is probably an easier way to do this, but I am not very good to figure it out...How would I go about making it look like this with question marks without making tons of "Board[9][9]" and more?
the map should look something like this at the very beginning....
Question
C++ Guy
Ok so I am making a Battleship game and I started to make the actual board for it. This is what I have so far:
#include <iostream> #include <fstream> #include <vector> #include <string> #include <conio.h> using namespace std; int global_ship_count = 10; int gameOver; int currentPlayer; int error; int input; int inputX; int inputY; int attack; int attackX; int attackY; int printY; int printX; string newLine; int hitCount; void CreateMap1(string mapArray1[10][10]) { for (int row = 0; row < 10; row++) { cout << "" << endl; for (int col = 0; col < 10; col++) { cout << mapArray1[row][col] << " "; } cout << endl; } } int main() { const int row = 10; const int col = 10; string Board[row][col]; Board[0][0] = "0"; Board[0][1] = "1"; Board[0][2] = "2"; Board[0][3] = "3"; Board[0][4] = "4"; Board[0][5] = "5"; Board[0][6] = "6"; Board[0][7] = "7"; Board[0][8] = "8"; Board[0][9] = "9"; Board[0][0] = "0"; Board[1][0] = "1"; Board[2][0] = "2"; Board[3][0] = "3"; Board[4][0] = "4"; Board[5][0] = "5"; Board[6][0] = "6"; Board[7][0] = "7"; Board[8][0] = "8"; Board[9][0] = "9"; CreateMap1(Board); system("Pause"); return(0); }There is probably an easier way to do this, but I am not very good to figure it out...How would I go about making it look like this with question marks without making tons of "Board[9][9]" and more?
the map should look something like this at the very beginning....
Player 1 | Player 2
123456789 | 123456789
1????????? | 1?????????
2????????? | 2?????????
3????????? | 3?????????
4????????? | 4?????????
5????????? | 5?????????
6????????? | 6?????????
7????????? | 7?????????
8????????? | 8?????????
9????????? | 9?????????
Link to comment
Share on other sites
4 answers to this question
Recommended Posts