× Main Menu

C# Tutorial – Create a Superhero Memory Game

In this tutorial we are going to create a full memory/matching game using superhero images. This tutorial is an advanced tutorial so it would be advantageous to go through some other tutorials before trying this one. However we have made sure you can follow it just as easily as others but its not just about making something work its about understanding the process.  This project is being developed in Visual Studio 2015 using the C# programming language. Everything is explained in detail please make sure you follow along accurately and feel free to double check your work if you are unsure of any elements while in development.

Lesson outcomes

  • Creating a full memory/matching game in visual studio using c# programming language
  • Using Picture Boxes
  • Using Picture Box Array
  • Using Vectors
  • Using Windows Form Events such as click and timer event
  • Detecting and assigning tags to picture boxes dynamically
  • Using Loops to detect active components in a Windows Form
  • Creating a count down timer for the game
  • Restarting the game once its been completed

Download the image resources for the memory game


9 responses to “C# Tutorial – Create a Superhero Memory Game”

  1. Jean Melkovsky says:

    var ssTime = TimeSpan.FromSeconds(time);
    What does this line do? The ssTime variable is not used anywhere in the code, is it? After I commented this line, the program compiled and run as intended, I didn’t notice any changes.

  2. dusan says:

    if (pictureBoxes.Any(p >= p.Visible)) return;

    the name ‘p’ does not exist in the current context ?
    what is p ?

  3. Sylar Dean Paginton says:

    I got this game code all correct but when i run the game it works fine up until i press the START button, then the game just freezes up and does nothing. I mean i cant even drag the game window around my screen or anything. I have to then shut the game running down via the stop button on the editor.

  4. Sylar Dean Paginton says:

    NVM, i got it working but playing it I run into a problem. Whilst playing the game sometimes one of the boxes will flip over to reveal no picture so then at the end your left with 1 picture and a blank picture, you can do nothing but wait for the timer to run out for it to reset. Another thing I found with this is that IF you use any other picture boxes.. (say to display a game logo or anything) when you press Start it will turn those pictures into the ? picture also.

  5. yemi says:

    where does the start game timer void start from in the coding?

  6. pingsu says:

    i tried this but it says:
    IndexOutofRangeException was unhandled
    Index was outside the bounds of the array.
    while (pictureBoxes[num].Tag != null);

  7. Anhar Ali says:

    Hi Yemi, the start game function starts in page 8. If you are unsure about where you are then go to the full code in bottom of the tutorial at page 13.

  8. help says:

    how do I have another picture box on the same form which isn’t included in the memory game

  9. Emilia Holmberg says:

    I have written the entire code exactly like you did, but when I run the program nothing happens. I can see the “start” button as well as the label with 00:60, but when I press the button, nothing happens. It doesn’t freeze, but nothing happens.

    Please help…

Comment on this tutorial and let us know how you got on -

%d bloggers like this: