Programming Assignment 7 (Match Game)

Write a Python program that implements the "match" game. You are given 8 image files each of which is 200 pixels in width and 200 pixels in height. The files names are p1.gif,...,p8.gif. If you wish, you may create 8 images of your own and use them in the program, but make sure that they are 200 pixels by 200 pixels in size. The program should work as follows:

  1. Initially, the program displays a window (840 pixels by 840 pixels) with 2 copies of each image randomly arranged in a 4 by 4 matrix as shown here. After 3 seconds all images are replaced by a different set of images that are available here. Click here to see how the new set of images look like. Note that the center point of the top left corner image is (120,120).
  2. The user then clicks on two images one after the other to see if they are matching images. After the first click, the program should display the hidden image under the clicked square and after the second click the program should display the image under the clicked square.
  3. If the two images clicked by the user are the same, the program should keep those images displayed (sample display). Otherwise, these two images should be replaced by the number images after 2 seconds. The display after several correct matches is shown here.
  4. The program continues in the above manner until all 16 images are opened. At this point the program should show the winning display. The file win.gif should be used in each of the 16 squares in the matrix. The winning display should also include the time taken by the user to match all images in the top as shown.
  5. Finally, the program should close the window canvas when the user clicks anywhere on the canvas.
You would need to learn the Graphics package available at Simple Graphics Library (courtesy Zelle) to solve this problem.

Some Sample Code using graphics.py.