Game Development Reference
In-Depth Information
Chapter 15
Redesigning the Game World
15.1 Introduction
Many things change over the course of running a game: many levels are completed,
the player's character may change, new quests and enemies are introduced, and so
on. In terms of programming games, this translates into more classes and changing
relations between instances of these classes. There are, however, also a couple of
things that will not change at all while a game is running. For example, the process
for loading sprites and sounds will probably stay the same throughout the game,
so the class that deals with this will not really change. Another process that is not
likely to change while a game is running is the random number generator. While
these processes might not change, a lot of different game objects use them. Some
objects need to access sprites or sounds, other objects might need the random num-
ber generator to initialize themselves. We have already proposed some solutions for
these problems. For example, we made the game world object and the random num-
ber generator static member variables of the JewelJam class so that they can be easily
accessed everywhere. However, the way that we deal with sprites currently is rather
cumbersome. We have to pass the content manager to all the constructor methods of
the game objects, and as a result, some sprites will be loaded multiple times. In this
chapter, we will investigate how to setup a class for dealing with various assets in a
game, an instance of which is accessible to all the objects that need assets such as
sprites and sounds.
15.2 Better Asset Management
15.2.1 Moving Sprites Around
In the game engine used in this topic, assets such as sprites and sounds are loaded
by the content manager as follows:
 
Search WWH ::




Custom Search