Beispiel #1
0
//----------------------------------------CREATING THE BOARD------------------------------------------\\

        // initialises the board by adding the array of buttons
        void initBoard()
        {
            Random r = new Random();

            // nested for loop that initialises an array of buttons
            for (int x = 0; x < btn.GetLength(0); x++)
            {
                for (int y = 0; y < btn.GetLength(1); y++)
                {
                    // creates new button object
                    btn[x, y] = new Button();
                    // sets dimentions and position of buttons
                    btn[x, y].SetBounds(60 * x, (60 * y) + 25, 60, 60);
                    btn[x, y].FlatStyle = FlatStyle.Flat;
                    btn[x, y].FlatAppearance.BorderColor = Color.FromArgb(17, 47, 65);
                    // generates a random number between 0 and 3
                    int colorNum = r.Next(4);
                    if (colorNum == 0)
                    {
                        // changes colour of button to red
                        btn[x, y].BackColor = Color.Red;
                    }
                    else if (colorNum == 1)
                    {
                        // changes colour of button to blue
                        btn[x, y].BackColor = Color.Blue;
                    }
                    else if (colorNum == 2)
                    {
                        // changes colour of button to green
                        btn[x, y].BackColor = Color.Green;
                    }
                    else if (colorNum == 3)
                    {
                        // changes colour of button to yellow
                        btn[x, y].BackColor = Color.Yellow;
                    }



                    //creates button click event handler
                    btn[x, y].Click += new EventHandler(this.btnEvent_Click);
                    // adds buttons to gui
                    Controls.Add(btn[x, y]);
                    multiLbl.Hide();
                    timeLbl.Hide();
                    scoreLabel.Hide();
                    plus2Lbl.Hide();
                    turnLbl.Hide();
                    CountdownLbl.Hide();
                    boardHomeBtn.Hide();
                    TitleLbl.Hide();
                    P1ScoreLbl.Hide();
                    P2ScoreLbl.Hide();
                }
            }
        }
Beispiel #2
0
        //shows the main menu
        void showMenu()
        {
            ClassicBtn.Invoke(new Action(() => ClassicBtn.Show()));
            ExitBtn.Invoke(new Action(() => ExitBtn.Show()));
            HelpBtn.Invoke(new Action(() => HelpBtn.Show()));
            multiplayerBtn.Invoke(new Action(() => multiplayerBtn.Show()));
            TimeBtn.Invoke(new Action(() => TimeBtn.Show()));
            menuBack.Invoke(new Action(() => menuBack.Show()));
            HomeTLbl.Invoke(new Action(() => HomeTLbl.Show()));
            boardHomeBtn.Invoke(new Action(() => boardHomeBtn.Hide()));
            CountdownLbl.Invoke(new Action(() => CountdownLbl.Hide()));
            TitleLbl.Invoke(new Action(() => TitleLbl.Hide()));

            if (gameMode == 2)
            {
                P1ScoreLbl.Invoke(new Action(() => P1ScoreLbl.Hide()));
                P2ScoreLbl.Invoke(new Action(() => P2ScoreLbl.Hide()));
                turnLbl.Invoke(new Action(() => turnLbl.Hide()));
            }
        }