C# form ile x’i yakalama oyunu nasıl yapılır?

Toolbox’dan eklenecekler: 17 Button, 1 Progressbar, 2 Timer.

public partial class’ın altına yazılacak:

        int xyakala = 0;
        int random;
        void buttonenabledf()
        {
            button1.Enabled = false;
            button2.Enabled = false;
            button3.Enabled = false;
            button4.Enabled = false;
            button5.Enabled = false;
            button6.Enabled = false;
            button7.Enabled = false;
            button8.Enabled = false;
            button9.Enabled = false;
            button10.Enabled = false;
            button11.Enabled = false;
            button12.Enabled = false;
            button13.Enabled = false;
            button14.Enabled = false;
            button15.Enabled = false;
            button16.Enabled = false;
        }
        void buttonenabledt()
        {
            button1.Enabled = true;
            button2.Enabled = true;
            button3.Enabled = true;
            button4.Enabled = true;
            button5.Enabled = true;
            button6.Enabled = true;
            button7.Enabled = true;
            button8.Enabled = true;
            button9.Enabled = true;
            button10.Enabled = true;
            button11.Enabled = true;
            button12.Enabled = true;
            button13.Enabled = true;
            button14.Enabled = true;
            button15.Enabled = true;
            button16.Enabled = true;
        }
        void buttonnull()
        {
            button1.Text = null;
            button2.Text = null;
            button3.Text = null;
            button4.Text = null;
            button5.Text = null;
            button6.Text = null;
            button7.Text = null;
            button8.Text = null;
            button9.Text = null;
            button10.Text = null;
            button11.Text = null;
            button12.Text = null;
            button13.Text = null;
            button14.Text = null;
            button15.Text = null;
            button16.Text = null;
        }

Form1_Load:

            timer1.Interval = 100;
            timer2.Interval = 500;
            buttonenabledf();

Button17_Click:

            progressBar1.Value = 0;
            timer1.Start();
            timer2.Start();
            buttonenabledt();

Timer1_Click:

            if (progressBar1.Value != 100)
            {
                progressBar1.Value += 1;
            }
            else
            {
                timer1.Stop();
                timer2.Stop();
                MessageBox.Show("Puanınız: " + xyakala.ToString());
            }

Timer2_Click:

Random rnd = new Random();
            random = rnd.Next(1, 17);
            if (random == 1)
            {
                buttonnull();
                button1.Text = "X";
                buttonenabledt();
            }
            else if (random == 2)
            {
                buttonnull();
                button2.Text = "X";
                buttonenabledt();
            }
            else if (random == 3)
            {
                buttonnull();
                button3.Text = "X";
                buttonenabledt();
            }
            else if (random == 4)
            {
                buttonnull();
                button4.Text = "X";
                buttonenabledt();
            }
            else if (random == 5)
            {
                buttonnull();
                button5.Text = "X";
                buttonenabledt();
            }
            else if (random == 6)
            {
                buttonnull();
                button6.Text = "X";
                buttonenabledt();
            }
            else if (random == 7)
            {
                buttonnull();
                button7.Text = "X";
                buttonenabledt();
            }
            else if (random == 8)
            {
                buttonnull();
                button8.Text = "X";
                buttonenabledt();
            }
            else if (random == 9)
            {
                buttonnull();
                button9.Text = "X";
                buttonenabledt();
            }
            else if (random == 10)
            {
                buttonnull();
                button10.Text = "X";
                buttonenabledt();
            }
            else if (random == 11)
            {
                buttonnull();
                button11.Text = "X";
                buttonenabledt();
            }
            else if (random == 12)
            {
                buttonnull();
                button12.Text = "X";
                buttonenabledt();
            }
            else if (random == 13)
            {
                buttonnull();
                button13.Text = "X";
                buttonenabledt();
            }
            else if (random == 14)
            {
                buttonnull();
                button14.Text = "X";
                buttonenabledt();
            }
            else if (random == 15)
            {
                buttonnull();
                button15.Text = "X";
                buttonenabledt();
            }
            else if (random == 16)
            {
                buttonnull();
                button16.Text = "X";
                buttonenabledt();
            }

Diğer Butonlar:

private void button1_Click(object sender, EventArgs e)
        {
            button1.Text = null;
            if (random == 1)
            {
                xyakala++;
                button1.Enabled = false;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            button2.Text = null;
            if (random == 2)
            {
                xyakala++;
                button2.Enabled = false;
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            button3.Text = null;
            if (random == 3)
            {
                xyakala++;
                button3.Enabled = false;
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            button4.Text = null;
            if (random == 4)
            {
                xyakala++;
                button4.Enabled = false;
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            button5.Text = null;
            if (random == 5)
            {
                xyakala++;
                button5.Enabled = false;
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            button6.Text = null;
            if (random == 6)
            {
                xyakala++;
                button6.Enabled = false;
            }
        }

        private void button7_Click(object sender, EventArgs e)
        {
            button7.Text = null;
            if (random == 7)
            {
                xyakala++;
                button7.Enabled = false;
            }
        }

        private void button8_Click(object sender, EventArgs e)
        {
            button8.Text = null;
            if (random == 8)
            {
                xyakala++;
                button8.Enabled = false;
            }
        }

        private void button9_Click(object sender, EventArgs e)
        {
            button9.Text = null;
            if (random == 9)
            {
                xyakala++;
                button9.Enabled = false;
            }
        }

        private void button10_Click(object sender, EventArgs e)
        {
            button10.Text = null;
            if (random == 10)
            {
                xyakala++;
                button10.Enabled = false;
            }
        }

        private void button11_Click(object sender, EventArgs e)
        {
            button11.Text = null;
            if (random == 11)
            {
                xyakala++;
                button11.Enabled = false;
            }
        }

        private void button12_Click(object sender, EventArgs e)
        {
            button12.Text = null;
            if (random == 12)
            {
                xyakala++;
                button12.Enabled = false;
            }
        }

        private void button13_Click(object sender, EventArgs e)
        {
            button13.Text = null;
            if (random == 13)
            {
                xyakala++;
                button13.Enabled = false;
            }
        }

        private void button14_Click(object sender, EventArgs e)
        {
            button14.Text = null;
            if (random == 14)
            {
                xyakala++;
                button14.Enabled = false;
            }
        }

        private void button15_Click(object sender, EventArgs e)
        {
            button15.Text = null;
            if (random == 15)
            {
                xyakala++;
                button15.Enabled = false;
            }
        }

        private void button16_Click(object sender, EventArgs e)
        {
            button16.Text = null;
            if (random == 16)
            {
                xyakala++;
                button16.Enabled = false;
            }
        }

Çıktısı:

Bu alana reklam verebilirsiniz!