Chapter 3. Helper Classes

In the Helper namespace I usually put a lot of helpful little tools and classes, which become quite useful over time. For a single project, it might not be the most important or valuable code, but because it is used again and again, no matter whether other parts of the engine change, helper classes will be the most consistent part of your engines and projects. Most of the helper classes don't have much to do with game programming, and they are useful in other projects or even in websites.

You just saw in the previous chapter that you can write a whole game without any helper classes and without even using any extra files or classes at all. But as the projects become bigger and bigger, you will see that there are a lot of repeating patterns and similar problems occur, which were already solved in the past. Usually most of the reused functionality in XNA is graphic components. In the next chapter and especially in the second part of this book, you learn more about game components and the graphics engine. For now, this chapter keeps the focus on the very basic functionality to log messages, access the game content, and do unit testing effectively, as well as how to generate random numbers, and many other smaller issues.

To make this chapter a little bit more exciting, you also create another little game just for the fun of it. Not all of the helper classes will be used, but building a game engine is not an easy task. For that reason, this and the next chapter ...

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.