Experiments In Game Programming
Main
 Home
XNA - C#
 Coming Soon!
 Level Editing - GTK
DirectX 9 - C++
 Downloads
 Disclaimer
 Introduction
Part 1 - DirectX
 1 - Breakout
 2 - Create DX
 3 - 2d Images
 4 - 3d Models
 5 - Cameras & Lights
 6 - Animation Timing
 7 - Keyboard/Mouse
 8 - Sound
Part 2 - Breakout
 1 - Art and Sounds
 2 - The Menu
 3 - Starting Breakout
 4 - The Level
 5 - The Paddle
 6 - The Ball
 7 - Finishing Touches

 

Introduction

 



DirectX is an intricate and complicated API, and can easily be overwhelming. When I started programming with DirectX I found myself swimming in the examples included in the SDK. I knew what I wanted to accomplish, but when searching through the mix of windows code, application code and directx calls I had no idea what was necessary and what wasn't. I wanted to get down to programming a game without worrying about learning all the details about setting up a window, or initializing directx present parameters.

My next step was to go to the internet and look for tutorials. They were few and far between. Most of them covered the basics, but left off right where I wanted to begin. Drawing points and lines is a great place to start, but I wanted to draw models and images.

This document is designed as a beginner’s introduction to game programming using DirectX 9. I only cover what we need to get going, and try to avoid going into detail about all the possible function parameters. I also try to be to the point about the functions I provide. Meaning you won't be drawing lines or triangles, instead you will be drawing images and 3d models. Everything is also separated into its own specific class, for example: a class for 2d drawing, a class for input, a class for sound, etc. That way when you are looking through each class you won’t be confused or distracted by code that is unrelated. It's written as a step by step tutorial for programming a 3d breakout style game from start to finish. If you follow through, you will be exposed to a variety of universal game programming concepts such as game loops, collision detection, and timing. You will also develop a library of directX interfaces for easily managing graphics, input, and sound that you can use in future projects.

Some notes on presentation:

Code will be presented in boxes such as this one.

Functions will be indicated in blue type.

Requirements:

It is assumed you know some C++, and some object oriented programming concepts. If you don't there are many good books on the subject, but if you know a little programming you should be able to pickup by example as we create our object classes. On that note, I will start slow and explain a lot of the basics, but by chapter 4 I will assume you know how to create objects and add classes to your project.

To use this code you will need the Directx9 SDK. It is available for download from microsoft.com. I have compiled and tested all code using the April 2005 version of the SDK.

The code was written and tested in Visual Studio .Net 2003. I assume you could compile it with other compilers, but it is not tested.

 

 ©2008 David Whittaker