Game Development Reference
In-Depth Information
If you take a look in the GameManagement library, you will see that all the classes
are public. As a result, they can be used in other projects.
Classes internal to the library— What is the use of having classes that
can only be used within a library and not outside it? The main reason that
this is important is that it allows software developers to make a distinc-
tion between the functionality that should be available to the outside users
and the functionality that is used inside the library. Suppose that we were
to develop a library for dealing with collisions. You could imagine that the
library exposes a number of classes to represent basic geometry used for
collision checking, but that the low-level math-related classes for calculat-
ing if objects collide are not visible to the user of the library. The down-
side is that the user does not have access to all the low-level functional-
ity. The upside is that the library documentation and design looks much
cleaner, so it is probably easier to learn how to use the library. It is not al-
ways clear which classes should be internal and which classes should be
external. Try to be consistent though, and for each class you develop for a
library, think beforehand if the class is for internal or for external use (or
both).
24.2.3 A Convenient GameEnvironment Class
While developing the different games, we have slowly extended the Game subclass
we used to incorporate more useful objects and methods. There is an input helper,
a game settings manager, a sprite batch, an asset manager, a method for going to
full screen mode, and much more. In order to allow for quicker game develop-
ment, we added a class called GameEnvironment that already contains all of these
things. If we want to create a new game, we simply have to make a subclass of
GameEnvironment , add our game states, and we are done. You can see this effect
in Listing 24.1 : a small class definition, containing only the things specific to the
Penguin Pairs game.
You can actually see that we are reusing all of these classes in the final game
developed in this topic, Tick Tick . If you open the solution belonging to the final
chapter in this topic, you will see that the Tick Tick game project has a reference to
the GameManagement library as well. As a result, all of the features we developed in
earlier chapters of this topic are instantly available to the game!
Search WWH ::




Custom Search