Alex Russell's Game Programming Tutorial using DirectX

Introduction . Chapter 1 . Chapter 2 . Chapter 3 . Chapter 4 . Chapter 5 . Chapter 6 . Chapter 7

Return to GameSmith home page .

Click here download the complete course (200 KB)


There are a number of tutorials available for the intermediate game programmer, but there are very few good tutorials for beginners who have never drawn a pixel on the screen. A quick search on the net reveals hundreds of sites devoted to 3D, polygons, texture- mapping and other advance topics, but the beginner has no where to get started. This tutorial is for C++ programmers who want to get an introduction to game programming.

This tutorial uses Microsoft's DX graphics library, but it does NOT teach you DX. A higher level "wrapper" library is used to hide much of the complexity of DX. Also, we are using DirectDraw to do 2D graphics. This is only supported up to DirectDraw V7. In V8 and higher DirectDraw has been folded into the 3D capabilities. No 3D programming is covered in this course. I recommend getting a good book on DX to learn how to use DX.

NOTE: in the years since this tutorial was written a new technology from Microsoft called XNA is now available. I highly reccomend XNA to anyone wanting to learn Windows game programming. XNA greatly simplifies using directX 2D and 3D. There are lots of tutorials and source code for XNA out there.This course is still good if you want to look at a lower level of game programming.

The course will be done in C++ using MS Windows and the DXSmith wrapper library. Download and install DXSmith from the Code Project. DXSmith is also at my site, but the local version has a few minor install issues. Get the CodeProject version if it's available.

MS has a free download of the core c++ tools here. It does not include the IDE, but does have all the command line tools required to compile and link win32 programs.


If you do not have these prerequisites you will find yourself consulting your c++ manuals quite a bit. I highly recommend that you have at least mastered the basics of c++ syntax. Here is a link to Yahoo's c/c++ page, including tutorials, and this is a good page for C Beginners too.


c++, including: pointers, structures, functions, basic data structures (e.g. linked list, stack), file i/o, and basic objects.

DirectX and DXSmith Library

DirectX SDK from Microsoft Download and install. You need the Developer's version. The DX runtime is used to run games, but the DX SDK is required to create new applications and games.

Download, install, and compile the DXsmith Library.

Basic knowledge of windows programming.

MS visual c++, V6.x. Other versions may also work, but the code has only been tested with V6. For a DOS based tutorial that only requires free components see: Alex Russell's Beginners DOS Game Programming Course.

Please DO install and compile the DXSmith library before trying to do this course. If you cannot compile the DXsmith library you will not be able to compile or run any of the sample code.


Chapter 1

  • Install DX and DXSmith
  • Install MS DX SDK
  • Install DXSmith
  • Compile DXSmith
  • Simple test program using DX Smith
  • Chapter 2

  • Double buffering
  • Graphic primitives
  • dots/pixels
  • horizontal lines
  • vertical lines
  • arbitrary lines
  • filled rectangles
  • Chapter 3

  • Sound and Music
  • Paying midi music
  • Playing digital sounds

  • Text

  • Blitting
  • Loading images from drawing programs
  • Display a bitmap
  • Sprites
  • Chapter 4

  • Animation
  • bouncing pixel
  • bouncing sprite
  • multiple bouncing sprites
  • Chapter 5

  • i/o
  • keyboard
  • mouse
  • joystick

  • combining all user input in one event queue
  • Chapter 6

  • Collision detection
  • rectangles only
  • Timing a game, and game design
  • * separating drawing from logic *
  • timing under windows
  • Chapter 7

  • Games
  • Break Out
  • Using a normal windows application (not a console program)
  • simple animation
  • collision detection
  • player control
  • Introduction . Chapter 1 . Chapter 2 . Chapter 3 . Chapter 4 . Chapter 5 . Chapter 6 . Chapter 7

    Copyright 2004 (c), Alex Russell, All rights reserved. Last Updated Feb 2004