dimanche 13 novembre 2016

C# How to Compare images with If statements

I'm trying to Compare 3 images for a slot machine, the problem is that im not getting any errors but the images don't seem to be getting compared to anything I have the images in an image list and they are being randomly selected but when imagebox1 is cherries the bettextbox wont = Winner ` public partial class Form1 : Form { public Form1() { InitializeComponent(); }

    Bitmap apple = Properties.Resources.Apple;
    Bitmap cherries = Properties.Resources.Cherries;
    Bitmap orange = Properties.Resources.Orange;

    private void spinButton_Click(object sender, EventArgs e)
    {
        Random rand = new Random();
        int pic = rand.Next(0, images.Images.Count);
        int pic2 = rand.Next(0, images.Images.Count);
        int pic3 = rand.Next(0, images.Images.Count);

        pictureBox1.Image = images.Images[(pic)];
        pictureBox2.Image = images.Images[(pic2)];
        pictureBox3.Image = images.Images[(pic3)];

        if (pictureBox1.Image == cherries)
        {
            betTextBox.Text = "Winner";
        }`

Aucun commentaire:

Enregistrer un commentaire