Summary
In this chapter, you have learned a lot of classes that will be useful in future projects. Unit testing is also an important knowledge point, and I want to persuade you to write unit testing first as a way to start game development. This chapter focuses on breakout games. This chapter contains a lot of content. Fortunately, you can skip some of the knowledge points of the breakout game, because many parts of the game can reuse the pong game in the previous chapter.
The center of the next chapter will be a little more on game programming and how to use components to build a game. This chapter shows the usefulness of the helper class. Now you are ready to extend this idea to the game.CodeThis is very important for creating more complex games.
Here is a summary of what you have learned in this chapter:
Try to use helper classes to encapsulate code into methods or helper classes, especially those that will be used multiple times.
Always write the unit test first and then perform the specific implementation.
Unit testing should be simple. You do not have to waste time writing unit tests that are too complex for the helper class, or make static unit tests more complex than the game itself. Unit testing is not important for the final game (in fact, you can use the # If debug command to exclude them), they just make your work more calm, helps you test and reuse new and existing code.
Each time you modify the code, you must run the unit test to ensure that no problem exists:
Use testdriven. Net to run a single test, or run each test in each class or namespace in Solution Explorer.
Or use nunit GUI for testing.ProgramAll unit tests in a set. For static unit tests, use the program class for manual tests.
Test the most complex parts of the game as much as possible, such as collision detection in the breakout game.