Chapter 5: Writing Your Own XNA Graphics Engine


Overview

In the first section of this book you learned all about the XNA Framework, rendering 2D graphics with the help of the SpriteBatch class, and you also made some fun games. Now it is time to explore the much more exciting world of 3D graphic programming. Creating 3D games is a lot more work than just putting together a 2D game, but many games would not be possible without the great advances in 3D graphic technology. Some games like strategy games are also possible in 2D, and the most successful strategy games of all times (StarCraft, WarCraft, Command & Conquer, Age of Empires) show that 2D games are still very popular. But if you take a look at shooter games, they would just not be possible without 3D graphics, and the better and more realistic the graphics get the more fun the games often are. Other game genres like beat-’em-ups, adventures, sport games, and so on have also benefited from the graphic advancements in recent years. Sure, Pong and the early tennis games were a lot of fun 10 or 20 years ago, but they don’t compare in any way with today’s sport games.

XNA is a great framework for quickly creating 2D games, and even if you are just an individual you will probably be able to quickly throw together a game idea, make some graphics or find someone to make some graphics for your game, and then program the whole game in a matter of weeks ormonths.

However, most game programmers are much more excited about creating 3D games, and a common mistake almost everyone makes is to compare their own game ideas with the most successful AAA titles that took big game studios many years to create. If you are an individual, you will probably not be able to compete with the next EA game, which will have had an experienced game studio with more than 100 people working on it, even if you think that their game will not be as good as it could be in your opinion.

But this does not matter; most of us got into the game development scene just because we like creating games and often because we think we can make it much better than all the other guys. The good thing is that although it is hard to create a full-blown 3D game that can compete with AAA titles, you have to start somewhere, and getting into the world of 3D programming is getting easier and easier as we speak. Many great websites, tutorials, frameworks, and books are available to quickly guide even very inexperienced programmers through the first steps of creating 3D graphics for games.

Because there are already so many resources available I will not focus on the math basics, how to work with matrices, or other 3D graphic basics. It would just be boring for many programmers that already know about it and it would take away many pages for more interesting projects in this book. The same way I told you in the first chapter that you should start by reading a C# book first if you are inexperienced with C#, I suggest if you really want to know all the basics about 3D graphics, pick up a book for that. If you have worked with Direct3D or OpenGL before you are good to go and should know all the basics already (hopefully that covers most of the readers here).

This chapter takes the classic approach of first writing down the requirements and creating the unit test for that and then goes into detail for every required new class you need. As the chapter name says, your goal is to create your own graphics engine and the basic framework for all the projects and games for the rest of this book. The Tetris game from the last chapter already had many useful helper classes and some new graphic classes that will be refactored in this chapter, and you will add some new classes. Refactoring means that the classes will be rewritten to fit your new requirements.




Professional XNA Game Programming
Professional XNA Programming: Building Games for Xbox 360 and Windows with XNA Game Studio 2.0
ISBN: 0470261285
EAN: 2147483647
Year: 2007
Pages: 138

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net