Chapter 4. Game Components
This chapter covers the Game
class and the game components you can add to it. To get your graphics engine up and running in the next chapter, you still need some new helper classes before starting with 3D concepts. The BaseGame
class is used to implement more features and to include all the other classes you have written so far. It is derived from the Game
class to take advantage of all the existing XNA features. In the same way our main test class TestGame
is derived from BaseGame
to help you execute static unit tests in your game. Then you will add the TextureFont
class to your Helpers namespace to allow you to draw text on the screen, which is not possible out-of-the-box in XNA. Finally, you also add some of the existing functionality from the previous chapters such as input, controller handling, and sound output into special classes to make it much easier to write a new game. Instead of speaking in the abstract, this chapter provides a concrete example game.
In contrast to the previous chapter you are not going to write any helper classes first, but instead you are going to write the unit tests and the game class first and then add all the game components you need to your project. In the last few projects, the problems were fairly simple and once you resolved them there was no need to go through them again. For the game you are going to develop in this chapter many improvements can be made and you will see this becomes even more true the bigger the ...
Get Professional XNA™ Programming: Building Games for Xbox 360™ and Windows® with XNA Game Studio 2.0, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.