Library sample chapters

Using Managed DirectX to Write a Game

Choosing the Game

This is a sample chapter from Managed DirectX 9 Kick Start : Graphics and Game Programming.

While many of the more advanced features of 3D programming haven't been discussed yet, there has been enough basic ground covered to write a simple 3D game. You will use the knowledge gained thus far, plus add a few new things.

Before we actually begin writing a game, it would be a good idea to come up with a plan. We will need to know the type of game we will be writing, the basic features it will hold, and so on. Given the limited set of topics we've covered this far, we obviously can't create something overly complex. Instead, a simple game will be written. One of the first demo games for MS-DOS was called "Donkey," in which the user controlled a car, and the goal was to avoid the donkeys in the road. Sounds simple enough; this chapter will make a 3D version, without the donkeys. We'll call this game "Dodger."

Before we begin actually writing some code, though, we need to spend a little bit of time planning and designing our game. What will we need for the game, and what do we want to do while playing it? Well, obviously, we'll need a car class to control our vehicle. Then it might be a good idea to have a class to control the obstacles we will be trying to avoid. Plus, we'll need our main game engine class that will do all of the rendering, and keep it all together.

If you were attempting to create a commercial game that you wanted to be published and sold in stores, you would spend a lot of time coming up with a game proposal. Game proposals are in-depth documents that detail the vast majority of the game concepts and features. Given that the scope of this book is intended to cover the actual development work, and not necessarily the steps that you would need to take in order to get it published, this exercise will be skipped.

Another recommended document that is normally required before development work starts is the technical specification ( spec for short). This includes a mildly detailed list of all the classes, plus the methods and properties the classes will implement. It may also contain UML diagrams that show the relationships between the objects. The goal of the spec is to sit down and really think about the design of your application before you start writing any code. Again, since the focus of this book is on the code, the spec for this project will be omitted as well. I would recommend that you always spend some time coming up with a spec before writing any code.

Comments

  1. 11 Jul 2007 at 17:39

    There is a typo in some of your code. Specifically in the OnDeviceReset event. At the start of the If/Then block that checks if lighting is supported, you call for a type (unit) which i believe you meant (uint). Other than that, this looks like a really good tutorial.

  2. 09 Aug 2005 at 02:32

    Ive just started game development , this code is really helpful to me and i think to others also which wants to start develoment in this adventures  field. Thanks for sharing this article. Ive learnt  so many things from this article  although i was enable to give it the final touch due to .x and textures file (im requesting Author to plz put a link for these file, so that me and other people can take help)


    thanks a lot for this very useful article


    Ankit Nagpaljavascript:smilie(':cool:')
    C# Programmer
    New Delhi

  3. 27 Apr 2004 at 02:15

    Your tutorial sounds great. Please include what kind of namespaces must be used in this project.

  4. 01 Jan 1999 at 00:00

    This thread is for discussions of Using Managed DirectX to Write a Game.

Leave a comment

Sign in or Join us (it's free).

AddThis

Events coming up

  • Dec 6

    Developing AJAX Web Applications with Castle Monorail

    London, United Kingdom

    Monorail is the model-view-controller engine of the Castle Project, bringing many of the best ideas of Ruby on Rails to the .NET world. In this talk, David De Florinier and Gojko Adzic show how Monorail makes it easy to develop .NET based AJAX applications, and how to use the Castle Project to build Web 2.0 applications effectively. Come to this session if you are a .NET web developer. Everyone is welcome!