"Memory" is a fun game that you may have played in "real life", with actual paper tiles. It's called that because the main skill in the game is your memory - how well you can remember the position of tiles. It's also a game that can be re-created on a computer, and is a good example of using computer memory to remember information, like with arrays.

Once we're done, this is what our "Memory" game will look like:

To make the game, we will need to re-create the physical parts of the game using our drawing commands and implement the rules of the game using variables and logic. We will make a single-player version of the game, which will simplify some of the logic. Here's an outline of what we'll implement:

  • The game consists of an even number of tiles with images on one side and a generic back. Each image appears on precisely two tiles.
  • When the game starts, all tiles are turned face down.
  • The player then flips over two cards, selecting them by clicking on them. If the two tiles have the same image, they remain face up. Otherwise, the tiles flip back over after a small period of time.
  • The goal of the game is to get all the tiles flipped face up (i.e., find all the matching image pairs) in the least number of tries. That means that lower number of tries are better scores.