in GomokuClient/GomokuClient/GUIController.cpp [105:129]
void GUIController::OnMouseEvent(int button, int state, int x, int y)
{
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
{
if (GRID_GAP / 2 < x && x < WINDOW_SIZE_W - GRID_GAP / 2 && GRID_GAP / 2 < y && y < WINDOW_SIZE_H - GRID_GAP / 2)
{
int adjLocX = x / GRID_GAP;
int adjLocY = y / GRID_GAP;
int adjSubX = x % GRID_GAP;
int adjSubY = y % GRID_GAP;
if (adjSubX >= GRID_GAP / 2)
adjLocX += 1;
if (adjSubY >= GRID_GAP / 2)
adjLocY += 1;
if (adjLocX > BOARD_SIZE || adjLocY > BOARD_SIZE)
return;
PutStone(adjLocX, adjLocY);
glutPostRedisplay();
}
}
}