CMSC 437/691C
Graphical User Interface Programming


TUE,THU 5:30-6:45 PM ACIV 150
Fall 1996


Project 1: A Concentration Game

This page was last updated on 19 September 1996, adding a link to my toggle.c example as well as clarifying the location of the demo code.
Date Due: Tuesday, September 24, 1996 before midnight.

Purpose

To familiarize you with X11, the Xt application programming model and simple Motif button widgets.

Assignment

You must write an interactive computer version of the card game Concentration. This is a simple game in which all of the cards are laid out face down and players take turns turning over pairs of cards attempting to find matching pairs. Once a matching pair is found, the cards are removed by the player who found the match until all cards are gone.

Your computer version will be simpler than this. Cards will be represented by Motif PushButtons or ToggleButtons with bitmap images to distinguish them. Cards will be turned over by clicking on the buttons. Initially, there will be twenty of these buttons (more if you wish) displayed on the screen with blank bitmap images on their faces. There will be ten distinct bitmap images randomly associated with these buttons, two buttons for each image, which will become visible when the mouse is clicked over the button. There will only be a single player (the user) who will repetedly select pairs of buttons. The first card/button pushed will reveal its bitmap image when the mouse button is pressed down and continue to display the image after the mouse button is released. The second card/button will reveal its bitmap image only when the mouse button is pressed. If this image matches the image of the previously selected button, then it will be displayed permanently. Otherwise it will revert to the blank bitmap image when the mouse button is released, and the previously selected card/button will become blank as well. This process will continue until all the card/button images are exposed.

In addition to the twenty card/buttons, the program will display a title, a "New Game" button which restarts the game with a new arrangement of cards, a running count of the number of turns played in the current game, and a record of the lowest turns of any game played to date.

Hints

We suggest that you start from an existing example program from the textbook, for example, one of the programs in Chapter 4 (please note which one in the comments). You may use either some of the existing standard X11 bitmap images located in /usr/include/X11/bitmaps, or create your own bitmaps using the pixmap utility (type man pixmap for more information). If you do use your own bitmaps, you must submit them with your program. There are several programming tips to do the project :

Here is the example shown in class on 9/17 which demonstrates explicitly loading a pixmap using the XmGetPixmap() call. It may be of some use, although of course you don't have to do things this way.

Demo Program

On the GL systems, a demo program will be provided for your reference which will run on the SGI lab workstations. You can find the binary code in directory ~ian/pub/guip/proj-ex/proj1/pplay with file name "pairplay1" (implemented by PushButton) and "pairplay2" (using ToggleButton). There is also a demo by a former student of the class in proj1/squire. These programs are only for demonstration and it is possible that some required features are not included, which you should develop by yourself. Be sure you have copied the Pairplay resource file to your home directory before use.

Project Submission

Projects will be submitted electronically using the submit utility program. Details of how to do this are available.