private void FlipTime_Tick(object sender, EventArgs e) { //Timer to flip back images to cover image FlipTime.Stop(); FlippedImage1.Image = Properties.Resources.cover; FlippedImage2.Image = Properties.Resources.cover; FlippedImage1 = null; FlippedImage2 = null; }
private void checkImages(PictureBox pic1, PictureBox pic2) { //Check if images are the same in both the PictureBoxes if (FlippedImage1 == null) { FlippedImage1 = pic1; } else if (FlippedImage1 != null && FlippedImage2 == null) { if (FlippedImage1 != pic1) { FlippedImage2 = pic1; } } if (FlippedImage1 != null && FlippedImage2 != null) { if (FlippedImage1.Tag == FlippedImage2.Tag) { FlippedImage1 = null; //Reassigning to null for the next set of values FlippedImage2 = null; //Same as above pic2.Enabled = false; //To avoid clicking the image pic1.Enabled = false; //Same as above ++FlippedCount; //To check if the game is over by checking if all images have been flipped ScoreCounter.Text = Convert.ToString(Convert.ToInt32(ScoreCounter.Text) + 10); //Score Increment if there is a correct match } else { FlipTime.Start(); ScoreCounter.Text = Convert.ToString(Convert.ToInt32(ScoreCounter.Text) - 5); //Score Decrement if there is a wrong match } } if (FlippedCount == 10) { //if all images are flipped over then reset the count value and call changeLevel() to check and go to the next level FlippedCount = 0; changeLevel(); } }