I have an assignment from the array and tile mapping chapter in my lesson which calls for me to creat a game that allows two players to play a game of Tic Tac Toe. The program should allow the players to use the mouse to click a location on the Tic Tac Toe board to place the X and O. The program will determine who has won or whether or not a tie has occurred. I have already written the code to display the board along with some void functions.
#include "DarkGDK.h"
void Draw();
void Input();
void CheckforWin();
bool mouseFullClick(int &, int &);
void DarkGDK ( void )
{
//Mouse points
int x = dbMouseX()/dbScreenWidth()/3;
int y = dbMouseY()/dbScreenHeight()/3;
//Player turn
int turn =1;
//Board Array
const int row = 2;
const int column =2;
int board[row][column];
//Draws the board
dbLine(205,1,205,501);
dbLine(445,1,445,501);
dbLine(1,168,670,168);
dbLine(1,345,670,345);
//Disable the auto refresh and set the
//Refresh rate.
dbSyncOn();
dbSyncRate(60);
// Game loop
while ( LoopGDK() )
// {
//Framework for turn order
Input()
Draw()
CheckforWin()
//Refresh the screen.
dbSync();
}
//Waits for user to press a key
dbWaitKey();
}
void Draw()
{
}
bool mouseFullClick(int &, int &)
{
// Variable to hold the return value.
bool buttonClick = false;
// If the mouse button is pressed, process
// a full clicking action.
if ( dbMouseClick() == 1 )
{
// Get the mouse pointer coordinates.
int x = dbMouseX();
int y = dbMouseY();
// Wait for the user to release the
// mouse button.
while ( dbMouseClick() == 1)
{
// Do nothing in this loop.
}
// Set buttonClick to true.
buttonClick = true;
}
// Return true or false to indicate whether the
// mouse was clicked.
return buttonClick;
}
What I need assistance with is the actual placing of board locations in an array. Also trying to figure out whether I need two Draw functions for the placement of the X and O, or just one function. If I could get some help with pointing me in the right direction that would be highly appreciated.