CMSC 437
Graphical User Interface Programming


TUE,THU 5:30-6:45 PM ACIV 015
Spring 1997


Project 1: A Concentration Game

Date Due: Tuesday, February 25, 1997, 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 repeatedly 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 completed 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 your program's comments). You may use either some of the existing standard X11 bitmap images located in /usr/include/X11/bitmaps, bitmaps from one of the demos, or create your own bitmaps using the bitmap utility (type man bitmap for more information). You must submit your bitmaps with your program!

Here are several programming tips:

Here is the example shown in class on 2/11 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; I think using resources is a much more elegant approach.

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). Be sure you have copied the Pairplay resource file to your home directory before use.

There is also a demo by a former student of the class in proj1/squire. It contains some nice card bitmaps which you may use (please give credit to Jon Squire!). These programs are only for demonstration and it is possible that some required features are not included, which you should develop by yourself.

Project Submission

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