4.1 Overview of this Chapter
This chapter mainly discusses Game Basic Principles of the class and related concepts of game components. In the next chapter, you will develop your own image engine, but before that, you need several new helper classes. Where Basegame Class is used to implement more features, and it will use all other helper classes currently. This class inherits from Game Class ( Microsoft. xNa. Framework. Game ) To use all existing XNa Features. Similarly, the main test class Testgame Inherited from Basegame Used to perform static unit tests in the game. In addition Texturefont Class, allowing you to draw text on the screen, Which is not possible out of the box in xNa . Finally, add some functions implemented in the previous chapters, such as user input, controller processing, and sound output, and encapsulate them into special classes. In this way, when developing a new game, it will make things easier. This chapter describes how to use an actual game example.
Unlike the previous chapter, this chapter does not start with the write helper class, but starts with the write unit test and the game master class, and then adds the game components to the project one after another. The problems encountered in the previous projects are very simple. once solved, there is no need to make improvements. However, the Games to be developed in this chapter have a lot of room for improvement, and the larger the game project, the more obvious this point. Processing the oldCodeAnd when improving the game, code refactoring is still the most important thing you must remember. Sometimes, you may even find that the code snippets in the unit test end with the final release of the game code.
Here we will use a Tetris game as an example. It supports the keyboard and Gamepad Input, there is a large game area, there will be blocks of different colors to fall, there is a area to show what is the next square, there is also a score panel that displays the current level, scores, and several rows of bricks are eliminated. If you are a Russian Square Game Fan and often play like me, this game will be very interesting to you. Tetris is the most popular Puzzle Arcade One of the games, it's Russian Alexey pazhitnov In 1985 Invented Nintendo In 1989 Release it Game Boy The system has always been popular.