I'm trying to make a simplified version of the Battleship game. I have an 2D array with 4x4 coloumms. I wanna randomize a cordinate (like 4:1 or 2:3) in the array so that the user can try and find the right cordinate from guessing. But I can't figure out how to randomly select one cordinate in a array?
Ok I'm halfway to crazy right now! Can't get this s*%t to work. The thought is to create an 2d vector where something is hidden on a cordinate. The user will then guess on where its hidden. If its wrong the console will display were the user guessed and offer a new try. If the user is right the console while display this and tell the user how many tries it took.
I cant figure how to display the array as :
0 1 2 3 4
in this example the user have guessed on 4/1 and 3/1 wich was wrong.
But I cant find a way to print the 2d array with the positions that have been guessed on?
attaching the code
plz help =(
int main ()
int row = rand()%4;
int col = rand()%4;
int rounds = 1;
int gameBoard [row][col];
cout << "==NEW SHOT!==" << endl;
cout << "Place your shot on the y-axle ";
cin >> y;
cout << "Place your shot in the x-axle: ";
cin >> x;
if (y == row && x == col)
cout << "*HIT*" << endl;
cout << "It took u " << rounds << " tries. Well done!";