Game Development Reference
In-Depth Information
Chapter 4
Creating a Game World
4.1 Introduction
In this chapter, we will show you how to create a game world by storing information
in the memory. We will introduce basic types and variables, and how they can be
used to store or change information. Next, we will show you how to store more
complicated information such as sprites and sounds, and how you can use them to
draw a nice-looking game world with sounds.
4.2 Basic Types and Variables
In the previous chapters, we have discussed memory a couple of times. We have
seen how we can execute a simple instruction like GraphicsDevice.Clear(Color.Olive);
to clear a window and to set a background color. In the next example, we are going to
use the memory to store information temporarily, in order to remember the results of
a few simple calculations. The example that we are going to look at is the DiscoWorld
example, in which we change the background color depending on the game time that
has passed.
4.2.1 Types: Different Kinds of Structured Information
The previous examples used different kinds of information that were passed as pa-
rameters to methods. For example, the method GraphicsDevice.Clear wants as infor-
mation a color, the Update method in the BasicGame class wants game time informa-
tion, and the LoadContent method does not need any information at all. The compiler
needs some way to distinguish between all these different kinds of information.
For example, it is useful to know what kind of information a method expects, so
that the compiler knows something is wrong when we try to execute the instruction
 
Search WWH ::




Custom Search