Game Development Reference
In-Depth Information
our example, we will use strings for these identifiers. The asset manager is going
to be a static member of the JewelJam class, so that any game object can access it
through a AssetManager property. So, we add the following declaration and property
to the JewelJam class:
protected static AssetManager assetManager;
public static AssetManager AssetManager
{
get { return assetManager; }
}
The asset manager object is created in the JewelJam constructor. Because the asset
manager needs a reference to the content manager, we pass it along as a parameter:
assetManager = new AssetManager(Content);
15.2.3 Loading and Retrieving Assets
Loading and retrieving a sprite asset is done in the GetSprite method. First, this
method checks if the string identifier that was passed along is not empty. If it is
not, we call the Load method of the content manager to retrieve the sprite. The Load
method is quite smart. It loads a sprite only once and it keeps track of which sprites
are already loaded in the game. Therefore, if you would call the Load method a thou-
sand times with the same sprite name, the sprite would get loaded only once. For
the complete AssetManager class, see Listing 15.1 .
Designing games— Although in game development teams the programmer
is normally not responsible for the design of the game, it is still very use-
ful to have a basic understanding of this process. The programmer must turn
the game design into code and must be able to advise the designer on what
will work and what will be difficult to achieve. For this collaboration to be
successful, everyone has to speak the same language.
Designing a game primarily consists of defining the game mechanics, the
setting of the game and the levels. Game mechanics involve such things are
the rules of the game, the way players control the game, the goals and chal-
lenges, and the reward structure. Psychology and educational science play an
important role here. They help you to understand how players get in the flow
(the mood in which they are fully committed to playing the game), how goals,
challenges and rewards can support each other, and how to vary and adapt the
difficulty of the game.
Search WWH ::




Custom Search