// Detects where the mouse is clicked and assigns it a x and y value. public void detectHit(Point loc) { // Checks if the board was clicked if (loc.Y <= 500) { int x = 0; int y = 0; if (loc.X < 167) { x = 0; } else if (loc.X > 167 && loc.X < 334) { x = 1; } else if (loc.X > 334) { x = 2; } if (loc.Y < 167) { y = 0; } else if (loc.Y > 167 && loc.Y < 334) { y = 1; } else if (loc.Y > 334 && loc.Y < 500) { y = 2; } if (movesMade % 2 == 0) { GFX.drawX(new Point(x, y)); holders[x, y].setValue(X); if (detectRow()) { MessageBox.Show("X Wins!"); reset(); GFX.setUpCanvas(); } } else { GFX.drawO(new Point(x, y)); holders[x, y].setValue(O); if (detectRow()) { MessageBox.Show("O Wins!"); reset(); GFX.setUpCanvas(); } } movesMade++; } }
private void rButton_Click(object sender, EventArgs e) { theBoard.reset(); GFX.setUpCanvas(); }