how to make a picturebox change its image quickly

Viewed 42

i have a problem, im making a game where the player needs to avoid his enemy's bombs, i coded everything. picturebox1 is the bomb, picturebox2 is the player, picturebox4 is the enemy. i want the bullet to change its image to another image which is the explosion state, and i use pictureBox1.Image = Properties.Resources.BulletExploded; for it. but the problem is: there are some other things in the if statement, here's the code:

if (pictureBox1.Visible == true)
        {
            var skystrikerloc = pictureBox5.Location;
            var bulletloc = pictureBox1.Location;
            int direction = -1;
            pictureBox1.Left += direction * 15;
            if (!this.ClientRectangle.IntersectsWith(pictureBox1.Bounds) || pictureBox3.Bounds.IntersectsWith(pictureBox1.Bounds) || pictureBox4.Bounds.IntersectsWith(pictureBox1.Bounds))
            {
                pictureBox1.Left += (pictureBox5.Left - pictureBox1.Left);
                pictureBox5.Top = r.Next(100, 200);
                pictureBox1.Top = pictureBox5.Top;
                pictureBox1.Image = Properties.Resources.Bullet_1_png;
                pictureBox1.Refresh();
                System.Threading.Thread.Sleep(500);
            }
        }

i want picturebox1 to change it's image into bullet exploded, but the player doesn't get to see the bullet exploding, the game restarts (the player loses) and THEN the bullet is changed, i know i can stop it from being in the explosion state after restarting, but the player doesnt get to see it before that, so if i did prevent it from being exploded after the game resets, the player will never get to see the explosion.

0 Answers
Related