Çözüldü C# zar kodu ne işe yarar?

Bu konu çözüldü olarak işaretlenmiştir. Çözülmediğini düşünüyorsanız konuyu rapor edebilirsiniz.

xBurakBey

Centipat
Katılım
15 Mart 2023
Mesajlar
21
Daha fazla  
Cinsiyet
Erkek
Merhaba. Bir C# kodu buldum kullanacağım ancak ne işe yaradığını çözemedim. Bilen biri yardımcı olabilir mi? Ödevimde kullanacağım ve önemli bir ödevdir.

Kod:
private void button1_Click(object sender, EventArgs e)
        {
            timer1.Start();
            button1.Enabled = false;
            hak--;

            if (hak == 0)
            {
                Form2 fr2 = new Form2();
                this.Hide();
                fr2.Show();
                fr2.sonuc1.Text = sonuc1.ToString();
                fr2.sonuc2.Text = sonuc2.ToString();

                if (sonuc1 > sonuc2)
                    fr2.sonucKazanan.Text = "1.Oyuncu";
                else if (sonuc1 < sonuc2)
                    fr2.sonucKazanan.Text = "2.Oyuncu";
                else
                    fr2.sonucKazanan.Text = "Berabere";
            }

        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            int zar1, zar2;

            int zar1_1 = rnd.Next(1, 7);
            int zar1_2 = rnd.Next(1,7);

            zar1 = rnd.Next(0, 6);
            zar2 = rnd.Next(0, 6);

            pictureBox1.Image = ımageList1.Images[zar1];
            pictureBox2.Image = ımageList1.Images[zar2];

            sayac1++;
          
            if (sayac1 == 10)
            {
                sayac1 = 0;
                timer1.Stop();
                button2.Enabled = true;
                sonuc1 += zar1_1+zar1_2;


                if (zar1_1 == 1)
                {
                    pictureBox1.ImageLocation = "1.png";
                }
                else if (zar1_1 == 2)
                {
                    pictureBox1.ImageLocation = "2.png";
                }
                else if (zar1_1 == 3)
                {
                    pictureBox1.ImageLocation = "3.png";
                }
                else if (zar1_1 == 4)
                {
                    pictureBox1.ImageLocation = "4.png";
                }
                else if (zar1_1 == 5)
                {
                    pictureBox1.ImageLocation = "5.png";
                }
                else if (zar1_1 == 6)
                {
                    pictureBox1.ImageLocation = "6.png";
                }



                if (zar1_2 == 1)
                {
                    pictureBox2.ImageLocation = "1.png";
                }
                else if (zar1_2 == 2)
                {
                    pictureBox2.ImageLocation = "2.png";
                }
                else if (zar1_2 == 3)
                {
                    pictureBox2.ImageLocation = "3.png";
                }
                else if (zar1_2 == 4)
                {
                    pictureBox2.ImageLocation = "4.png";
                }
                else if (zar1_2 == 5)
                {
                    pictureBox2.ImageLocation = "5.png";
                }
                else if (zar1_2 == 6)
                {
                    pictureBox2.ImageLocation = "6.png";
                }
            }

            puan1.Text = sonuc1.ToString();
        }
 
Son düzenleyen: Moderatör:
Çözüm
Kullanıcıdan hak girişi alınıyor. 2 defa zar atıyor. Zar sonucuna göre picturebox üzerinde resim gösteriyor. Ardından sonuçları Form2'ye aktarıyor.

Geri
Yukarı