Exemplo n.º 1
0
        /// <summary>
        /// Initializes game form, creates grid of squares
        /// </summary>
        public TicTacToe()
        {
            int x = LEFT;
            int y = TOP;

            InitializeComponent();

            //creates grid of squares and adds them to the form
            for (int i = 0; i < NUMBER_OF_ROWS; i++)
            {
                for (int j = 0; j < NUMBER_OF_COLUMNS; j++)
                {
                    squares[i, j] = new Square(HEIGHT, WIDTH, x, y);
                    squares[i, j].Click += changeValue;
                    this.Controls.Add(squares[i, j]);
                    x += WIDTH;
                }
                y += HEIGHT;
                x = LEFT;
            }
            btnFillRandom.Enabled = false;
            MessageBox.Show("Welcome to Tic Tac Toe!\n"+
            "Two people can play against each other, or one person can play against the computer.",
            "Welcome to Tic Tac Toe!");
        }
Exemplo n.º 2
0
 public TicTacToe()
 {
     for (int i = 0; i < NUMBER_OF_ROWS; i++)
     {
         for (int j = 0; j < NUMBER_OF_COLUMNS; j++)
         {
             squares[i, j] = new Square();
         }
     }
     InitializeComponent();
 }