How Does the Game Play?


The idea behind the Brainiac game that you design and develop in this hour is to present a grid of paired tiles. More specifically , a 4x4 grid contains sixteen tiles, so eight pairs of tiles are randomly placed on the grid. Each of the pairs of tiles has a unique image that you use to match up the pairs during the game. The unique image on the tiles is hidden when you start the game, and is only revealed as you click tiles and attempt to match them. So, when tiles are unmatched, you see a common tile image that makes the different tiles indistinguishable. It's sort of like having a bunch of playing cards laid out face down. Figure 8.1 shows the grid of tiles in the Brainiac game and how they might be arranged for matching in pairs.

Figure 8.1. The Brainiac game consists of a 4x4 grid of randomly arranged tiles that are matched in pairs.

graphics/08fig01.gif

The game proceeds by allowing you to pick one tile, and then another. If the two tiles match, they are left visible and you move on to try and find two more matching tiles. If they don't match, they are flipped back over to remain hidden again. Your job is to remember the positions of the tiles as you turn them over so that you can match them up. The game keeps track of how many attempts it takes to finish matching all the tiles and reports the total to you when you finish. This total is essentially your score for the game, and is a good incentive to play more and work on your memory skills.

In case you haven't thought about it, the Brainiac game is a perfect game for mouse input. The most intuitive way to play this kind of game is by pointing and clicking the tiles with the mouse, so in this lesson the only user interface you'll build in to the game is mouse input. It wouldn't be a terrible idea to add keyboard and possibly even joystick support as an enhancement, but I didn't want to add unnecessary code at this point. Keep in mind that both the keyboard and joystick would have to use an additional graphical component in order to work. For example, you would have to come up with some kind of selection or highlight graphic to indicate which tile is currently selected. The mouse doesn't require such a component because you already have the mouse cursor to use as the basis for selecting tiles.

I realize that this probably isn't the most fanciful game you might have envisioned as your first complete game, but it is pretty neat when you consider that it does present a challenge and allow you to play and win. Additionally, the Brainiac game is a fun little game for incorporating your own images into the tiles and personalizing it.



Sams Teach Yourself Game Programming in 24 Hours
Sams Teach Yourself Game Programming in 24 Hours
ISBN: 067232461X
EAN: 2147483647
Year: 2002
Pages: 271

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net