Game Development Reference
In-Depth Information
Chapter 24
Finishing the Game
24.1 Introduction
In this chapter, we will finalize the Penguin Pairs game. As a first step, we will reor-
ganize our code a bit so that parts of it are more easily usable by other programs.
Then, we will finish the game by extending the user interface and adding sound
effects and music.
24.2 Separating Code into Different Libraries
Until now, we have developed three different games in this topic. These games are
quite different: we made a shooting game, a pattern-recognition game, and a more
complicated puzzle game consisting of different levels. Even though the types of
these games are quite different, there are a lot of similarities as well. For example,
all three games have some concept of a basic game object, and both the Jewel Jam
game and the Penguin Pairs game use a grid as a basis for their playing field. Also, the
concept of a hierarchy of game objects that are drawn on several layers is something
that is used in different games. All in all, we keep going back to using similar classes
among different games. In fact, we even copied classes from the Jewel Jam game,
and used them as is in the Penguin Pairs game.
As we have already discussed a couple of times in this topic, copying around
code is a bad thing. Making copies of code means that bugs can be copied as well,
and if we make any changes or improvements, we would have to do it everywhere
we copied that code. So how can we avoid copying code between different projects ?
For that, we can use a library . A library is basically a separate project in a solution
that contains code that is useful for several other projects. When a project wants to
use a library, we have to put a reference to that library in our project, just like we
have to do with a content project.
 
Search WWH ::




Custom Search