Y
Y
yuharu2015-10-19 12:01:42
C++ / C#
yuharu, 2015-10-19 12:01:42

Question about implementing tic-tac-toe with Windows Forms?

My task is to implement a game of tic-tac-toe on the field 15 by 15. The one who first collects a combination of 5 consecutive crosses (or tic-tac-toe) wins. Made the console version, everything is fine. Now the rendering problem. I don't know how to make this field. There is only one option so far: create 225 graphic buttons. Are there other options? If not, how do I implement this one. When a button is clicked, I should get the indexes of the button's location array. That is, in theory, I need a two-dimensional array of buttons.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
Zelimkhan Beltoev, 2015-10-19
@yuharu

Are there other options?

It would be much easier to select a play area, say, 750x750 (50px per cell), and when the user clicks anywhere in this play area, get the click coordinates and determine which cell was touched. And then according to your console algorithm:
This is much better than 200+ buttons

D
Dmitry Kovalsky, 2015-10-19
@dmitryKovalskiy

You can try to draw using the DataGridView, you can, like a sapper, with a lot of buttons.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question