Rocket Commander Tutorials
- Posted: Nov 06, 2006 at 1:17AM
- 8,647 views
- 22 comments
Loading user information from Channel 9
Something went wrong getting user information from Channel 9
Loading user information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
|Welcome to the Tutorials of Rocket Commander. You will learn step by step in ten 30-minute video tutorials how to develop a game like Rocket Commander. This can be your introduction into the world of game development.|
Time Required: Greater than 10 hours
Software: Visual C# Express Edition
Welcome to the Tutorials of Rocket Commander. You will learn step by step in ten 30-minute video tutorials how to develop a game like Rocket Commander. This can be your introduction into the world of game development. If you just want to play a bit, check out http://www.rocketcommander.com/ and download the game there (10 MB).
You can also take a quick look at the source code (which is freely available like the game) or get an overview about the project by looking at the Class Overview. There are around 20,000 lines of code and maybe 50 classes. Sounds like a big project, doesn't it? But we will take a look at the most important classes and even learn in Tutorial 4 how to write our own graphic engine in less than 30 minutes. If you decide to take a deeper look at the source code after watching the tutorials, it will hopefully help you out understanding a lot of the game mechanics because the source code is heavily commented as it should be in professional projects. If you have more questions, want help or meet with other developers starting in game development, visit the RocketCommander Forums.
This tutorial is targeted to people, who already know how to program in C# and have basic knowledge of Managed DirectX. If you are not experienced with .NET and programming languages like C# or VB.NET please start with more basic tutorials and webcasts first and return to this one later. If you are looking for Managed DirectX tutorials, start with the ones in the DirectX SDK and check out the many free tutorials available in the internet, Coding4Fun is a good starting point. If you want more links check out the Links, webcasts and Tutorials below.
This tutorial tries to give you more practical view on coding and games than many other tutorials, which only show you a couple of tricks in 100-1000 lines of code. You can write down this amount of code without many comments and it can still be followed. But in bigger projects you need much more documentation, comments and planning. If you reach 20,000 lines of code (or 100,000–500,000 lines in bigger projects), you need more structure, a clean programming style, and a constant amount of refactoring. So what is refactoring? You will learn about it along with Unit Testing in the first two tutorials. Refactoring lets you restructure and rewrite your code without changing the functionality to improve maintainability and your coding style, sometimes to improve performance too.
There are many open source projects (even games), but most of these projects lack good documentation, have not enough comments in the code, and often there are no tutorials for them. Sadly, many of these projects are canceled or are discontinued. It can be interesting to look at open source projects, but for beginners this is often very confusing and not helpful. These tutorials try to fit in between and will give you both a big project with source code and hopefully an easy way in.
Okay, let's begin. The following steps are also explained in detail in the first video tutorial. If you have any difficulties watch it and follow it step by step. First of all, we need Visual Studio 2005! If you don't have Visual Studio 2005 right now and don't have any money to buy the Standard or Professional (or, if you are crazy, rich the Team System version), there is also a free version: Visual C# 2005 Express Edition. It is not as powerful and you can't use any add-ins, but it is good enough for our game. You can also use any other version or IDE that supports .NET 2.0. You can freely download Visual C# 2005 Express here.
First of all, start with installing Visual Studio 2005. If you already have it installed, skip this step.
You should also install the MSDN help. If you don't do this you can still access the help online, but this makes searches take a much longer time.
Next you need the DirectX SDK, which you can directly download from the Microsoft DirectX page: Microsoft DirectX Developer Center
When installing it, you should select installing the Redistributable in the custom setup step too. You will need it if you want to install your game on other computers. When DirectX is installed you can check out the newest features by taking a look at the samples with the DirectX Sample Browser. If you haven't worked much with Managed DirectX before check out the documentation and tutorials.
Last but not least we need NUnit, which you can get from http://www.nunit.org/.
You may ask, "why do I need NUnit?" Well, Rocket Commander is based on Unit Tests and uses the Agile Methology. In the first two tutorials I will go into details of what this is all about and give you some examples. In short this means that we don't fully design everything in advance and do incorrect planning because we can't know better when inventing new stuff. Instead we do a short concept (see Tutorial 2), but we adjust it dynamically as we go along. Unit Tests in our code allow us to make sure everything still runs as expected even if we have to make drastic changes in design. A lot of mini-test-programs inside the code allow us to constantly check features and play around with our engine.
If you are using Visual Studio 2005 Team System you can also use the Unit Testing features implemented directly in VS there. Alternatively there are also other Unit Testing Frameworks around (e.g., MbUnit, csUnit, etc.) and for Visual Studio 2005 Standard and above you can also use TestDriven.NET (a plugin to start Unit Tests from your IDE). For this tutorials we will try to keep things simple and only use very basic features of NUnit.
(Click image to zoom)
This is the project overview. It may be a little bit confusing when looking at it for the first time, but later this graphic will help us out understanding the classes and game engine. The program starts with the Program class (upper left) and this is where we start with Tutorial 1 too. The class overview and the Graphic Engine are explained in the following tutorials. You could say that any class that display anything on the screen is derived from IGraphicObject. For the first couple of tutorials we are happy with just the Texture and Model classes. We can do quite a lot with DirectX, but abstracting it a little bit more give us the advantage not having to write the same code over and over again. This is very important for our graphic engine.
The second tutorial also explains the concept of the game. Our understanding of the classes is not very advanced right now, but we take a step back and think about the game itself. In the third tutorial we take a look at the helper classes. In the fourth tutorial we will write our own graphic engine in less than 30 minutes. This will help your understanding the graphic engine a lot faster. In the following tutorials we then go into each part of the game until we have the full game together in the last tutorial and are ready to write our own modification.
Tutorial #1. How do I setup Visual Studio for our project?
Explains all required steps to install Visual Studio Express and where to get Managed DirectX (Feb06 or better). But not only that, we will also drive deep into the common tools used in game development, including: CodeRush, FxComposer, 3DSMax8, ZBrush, Panda exporter for X-files, Photoshop, Paint.NET. At the end of the tutorial we are going to take a quick look at the project and all classes. Then we write our first unit test to check out some of the cool features in the engine. The unit test is basically a Model Viewer and shows an animated model from the game in space.
Tutorial #2. Design and Concept:
We are writing the concept for our game. You will see the concept of Rocket Commander before the first line of code was ever written and we go into detail about the concept and classes that were planed back then. We have a lot of great ideas in this phase, but we while this step is very important and projects that don't do any concepts are usually doomed, we still want to start coding and see some cool stuff on the screen. So at the end of this tutorial we write another unit test and render an Asteroid in Space (just 20 lines of code). Then we extend this idea and render a whole field of asteroids until we get a good understanding what classes are required in Rocket Commander to handle all that for us.
Why do we need them? In this tutorial we learn why it is very useful to write so-called helper classes instead of doing the same thing over and over again. These classes will cut down the amount of code we have to do later by a great extent and will make our project much more manageable and easier to understand. We will take a look at the ElapsedTime, Log, StringHelper, RandomHelper, WindowsHelper, etc. classes. We also write a couple of Unit Tests and see why Test-Driven Development is so useful.
Tutorial #4. Graphic classes:
We learn in just 30 minutes how to write our own 3D Engine with help of Test-Driven Development. We don't just create classes for rendering textures and models, but also for rendering fonts on the screen. For the textures we use DDS-Files and the models use the X-File format from Microsoft. This tutorial answers questions like:
Tutorial #5. Music and Sound:
Introduction to DirectSound and DirectX AudioVideoPlayback classes. These are the base classes for sound (.wav) and music (.mp3) playback. We will also learn in several unit tests how to adjust the volume, stereo balance and the frequency of wav files we play back.
Tutorial #6. Shader Introduction (TangentVertex class and FxComposer):
In this tutorial we are finally getting to the more interesting parts of Rocket Commander: Shaders. We check out some current games and compare some screenshots of scenes with and without shaders. Then we go into detail why shaders are so important for games in these days. We learn the differences to the Fixed-Function-Pipeline rendering and go depth into shader Development with FxComposer. We are also learning about the base classes in our engine and the used VertexFormat. To make things more clear we create our own shader class and write a simple, but effective SpecularPerPixel shader with Pixel Shader 2.0.
Tutorial #7. Shaders (Parallax, Instancing):
Now we finally get to the advanced shaders. This tutorial will let us produce very stunning effects. At first we do a comparison of today games again and take a look at the used shader techniques. Then we learn step by step the ParallaxShader used in Rocket Commander. We see both how it was developed in FxComposer and how the class in Rocket Commander works together with the ParallaxShader.fx file. We then write our own unit test and check out the textures for this tutorial in the engine.
Tutorial #8. Post Screen Shaders:
To make our scene even better looking we apply so called Post screen shaders to our scene. These shaders will manipulate the final image we have rendered on the screen and make everything appear much more consistent. First of all we start with FxComposer again and take a look at existing Post Screen Shaders and then we took a look at the more complex Post Screen Shader in Rocket Commander. We will take a look at Sepia, Sky cube mapping, Bloom, Glow, HDR und Motion Blur effects. Finally we analyze the shader classes in the engine and test these.
Tutorial #9. Input and Interface:
In this tutorial we will learn how to use the DirectInput classes and how Rocket Commander manages all Keyboard and Mouse input with help of several helper classes. Then we take a quick look at the Menu and User Interface classes in the game. This is usually a lot of work and can't be done in 30 Minutes, but we will see again that using some helper classes will greatly improve our productivity. Also reuse code as much as possible, this does not only make the coding easier, but also gives a more consistent look and feel to the final product. We take a look at the graphics created by the artists and see how we can manipulate and exchange (often called skinning) them, which is important for our next tutorial.
Tutorial #10. Game logic:
We have now all our basic elements for our game engine and can finally implement some game logic. Eighty percent of the tutorials did not really explain much of the game principles in Rocket Commander, but how the engine works. To leverage this knowledge we will learn how to extent the game. As an example we develop Flower Commander, which is a total conversion of Rocket Commander with just few very simple changes in the code.
As you can see on the screenshots the whole game looks much different, even the main menu looks different. All this is done by just exchanging three or four textures and one model (the flower instead of the asteroids). The game principle changes also a little: Instead of evading asteroids, we have to collect flowers now. We are not sitting inside a Rocket anymore, but we are a bee trying to collect honey (sounds crazy, but it is actually fun). Additionally we learn a lot of tricks and tips because the tutorial shows you that creating a mod can cause some problems, and instead of ignoring them we will check out what when wrong and learn how to adjust the game to our needs.
Our game now consists of: Input, Interface, Game logic, Helpers, Music, Sound, Graphics: Shaders, ParallaxMapping, TangentVertex helper classes, Instancing, Post Screen Shaders, Models, Fonts, Materials, Textures, Lens Flare effects.
More tutorials might be done at a later point in time. Tutorial #10 mentions a couple of interesting topics: More extensibilities, physics, game screens, manager classes, space camera, player and multiplayer capabilities, etc.
If you are searching for more .NET or DirectX websites or tutorials, check out the following links: