Hey there, i'm new to C++ programming (as you can probably can tell). After learning the basics from the Cprogramming.com site, i decided to create my own little game (Battleships).
I just started working and i already got a problem. For some reason, my board() function doesn't work and it doesn't display the player's board when i call it.
I don't know what could be the problem. I checked it several times and i can't see anything wrong with it.
Here's my entire code, i case my problem lays somewhere else:
Code:
#include <iostream>
using namespace std;
short plyrBoard[9][9];//The player's board status, his ships' locations and stuff like that.
short plyrView[9][9];//The PC's status as the player sees it (hits/misses).
short aiBoard[9][9];//The PC's full board status
short aiView[9][9];//The player's status as the PC sees it
short brd[9][9];//The basic board
/* Key:
0 = Empty
1 = Boat
2 = Ship
3 = Submarine
4 = Aircarrier
5 = Damaged or destroyed */
void board(); //Displaying the player's board
void boardCreate(); //Creating the diffrent boards (should only used once)
int main()
{
cout<<"Welcome to BattleshipsAI by TheYeIIowDucK!\n\n\n\n\n\n\n"<<endl;
cout<<"Start by choosing your ships' positions."<<endl;
void boardCreate();
void board();
short rdy;
do
{
//This part is under construction...
} while (rdy == 0);
}
void boardCreate()
{
short i;
short l;
short k = 8;
for (i = 0 ; i < 9 ; i++)
{
k = k + 2;
for (l = 0 ; l < 9 ; l++)
{
k++;
brd[i][l] = k;
plyrBoard[i][l] = 0;
plyrView[i][l] = 0;
aiBoard[i][l] = 0;
aiView[i][l] = 0;
}
}
}
void board()
{
short i;
short l;
for (i = 0 ; i < 9 ; i++)
{
for (l = 0 ; l < 9 ;l++)
{
switch (plyrBoard[i][l])
{
case 0:
cout<<brd[i][l]<<" ";
break;
case 1:
cout<<"BO ";
break;
case 2:
cout<<"SH ";
break;
case 3:
cout<<"SU ";
break;
case 4:
cout<<"AI ";
break;
case 5:
cout<<"XX ";
break;
default:
cout<<"ERROR";
break;
}
}
cout<<"\n"<<flush;
}
}
That's what i get:
http://img837.imageshack.us/img837/3...8201014024.png
Any help on this one?