I am trying to make a single player connect four game in C++. With the specifications being:
- 7x6
- In order to win, the player must match four games pieces either horizontally, vertically, or diagonally.
- One player, playing against a computer that makes random inputs.
I'm confused on how to write the functions to get the users inputs and to declare a winner.
If anyone has an example or snippets i could look at it would be much appreciated.
This is the code i have so far, it only deals with the game board. I am confused on what to do next.
Thanks.
void Initialize(char Slots[ROWS][COLUMNS])
{
// Sets up Game Board
for (int r = 0; r < ROWS; r++)
for (int c = 0; c < COLUMNS; c++)
Slots[r][c] = EMPTY;
}
//-------------------------------------------
void PrintBoard (const char GameBoard[ROWS][COLUMNS])
{
cout << " 0 1 2 3 4 5 " << endl;
cout << "|-----------------------|" << endl;
for (int r = 0; r < ROWS ; r++)
{
cout << "| ";
for (int c = 0; c < COLUMNS; c++)
{
cout << GameBoard[r][c];
cout << " | ";
}
cout << endl << "|-----------------------|" << endl;
}
}
//-------------------------------------------
int main ()
{
// Declare Variables
char GameBoard[ROWS][COLUMNS]; // Array for tracking the game
// Initialize the board
Initialize(GameBoard);
// Display Game Board
PrintBoard(GameBoard);
return 0;
}