17.3 Other selection games

A weakness in the PickNPop game is that playing it requires so little thought. A simple type of game that requires thought is the Memory style game. In this kind of game, the user tries to click on some desired shape that is hidden by some more generic shape. The classic Memory game uses a set of pairs of cards with pictures, with all cards turned face down, and the player turns over one card and then tries to turn over a card with a matching image. If two matching cards are found they're removed, a point is scored, and the player gets to continue the turn. If a non-matching card is found, the cards are turned face down again, and the player's turn ends. Either an opponent (possibly a robot) gets a turn then, or the original player gets a new turn, with the point of the game being to get all the cards with as few separate turns as possible. As the turns go by, the player learns the location of some of the cards, and presumably can remember these so as to do better on the following turns.

In a Memory game, you might use a cCritterMemory that has a BOOL _showcontents field and which has an extra sprite field cSprite *_pspritehide. You would need to take care of initializing this field in the constructor and deleting it in the destructor. The draw method could then be overridden like this, or see Exercise 9.10 for a more object-oriented solution.

void cCritterMemory ::draw(cGraphics *pgraphics, int drawflags) 
    if (_showcontents) 
        cCritter::draw(pgraphics, int drawflags) 
        _pspritehide->draw(pgraphics, drawflags); 

There are many other selection game possibilities. One type is puzzles where one slides things around. For some good examples of puzzle games see the website of the master puzzler Scott Kim, www.scottkim.com.

    Part I: Software Engineering and Computer Games
    Part II: Software Engineering and Computer Games Reference