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.
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.