Game Development Reference
In-Depth Information
This same type of setup code can be used to start any number of projects, so it's
worth keeping it as a file somewhere or refactoring it into the engine. The Up-
dateInput code has had to change from our earlier examples. There are two
classes with the same name— Point . One Point is from System.Drawing
and the other is from our Engine library. To let the compiler know which point
we mean, the fully qualified name is used; for example:
// Using the fully qualified name removes potential confusion.
System.Drawing.Point point = new System.Drawing.Point();
Engine.Point point = new Engine.Point();
Running this test program will produce a blank screen, which means that ev-
erything is working as expected. This project can now be used to run any engine
tests required. Extra game states can be added as required. The engine currently
doesn't support multiple textures very well so that will be the next change.
Multiple Textures
The engine library currently handles sprites with differing textures poorly. To
demonstrate how it handles different textures, create a new game state called
MultipleTexturesState . As with earlier states, this should implement
IGameObject and be loaded using the StateSystem . This state will be test-
ing the texture system; therefore, it will also need to take a TextureManager
object in its constructor. The loading code can be placed in the In-
itializeGameState method in form.cs.
private void InitializeGameState()
{
// Load the game states here
_system.AddState("texture_test", new MultipleTexturesState
(_textureManager));
_system.ChangeState("texture_test");
}
This new state will need to create sprites with different textures. Two new tex-
tures are provided on the CD in the Assets directory: spaceship.tga and space-
ship2.tga. These are large low detail sprites of two different spaceships. Add these
.tga files to the solution and set the properties so that they will be copied into the
build directory.
 
Search WWH ::




Custom Search