Alex Russell's Dos Game Programming in C for Beginners
A Tutorial

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

Return to GameSmith home page .

Alex Russell's Game Programming Tutorial using DX

The above course uses a DX wrapper and MS VC++ to teach the basic of game programing.

alexander.russell@telus.net

Click here download the complete course (200 KB)

Introduction

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.

The course will be done in C using dos 16bit real mode. The video mode is 0x13 (320x200, 256 colours). This has been chosen for simplicity, and availability.

A Note on Compilers

All of the sample code is 16bit dos code. It will not compile if your compiler is making a windows CONSOLE program. A win32 console program looks like a dos program, but is a win32 application that cannot use the interrupts, or access video memory as required. MS VC++ V1.52 is the last version of VC to support creating dos programs. Please check your compiler's documentation to make sure it supports a 16bit real mode dos exe. DJGPP, a popular free 32bit compliler will not work with this code. Borland gives away Turbo C V2.0 at their web site and will work fine with all the C samples.

Prerequisites:

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.

Required:

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

Optional

ASM: x86 - there is a little bit of ASM code used to access hardware.

Why DOS?

DOS is dead, but it is a great environment for learning the underlying principals of game programming. All the main principals that are used for any platform can be learned in an easy to use, and popular operating system.

Outline

Chapter 1

  • Quick overview of c
  • pointers
  • structs
  • functions
  • dynamic memory allocation
  • include files
  • file i/o
  • memory models, why we will use medium
  • global variables, and other evils

  • Entering mode13h, via int86
  • mode13h details
  • saving and restoring old video mode
  • Chapter 2

  • Double buffering vs. page flipping, and syncing to vertical retrace
  • Graphic primitives
  • dots/pixels
  • horizontal lines
  • vertical lines
  • arbitrary lines
  • filled rectangles
  • Chapter 2.1

  • More graphic primitives
  • solid sprites
  • transparent sprites
  • RLE transparent sprites
  • restoring backgrounds
  • graphic text

  • Loading images from drawing programs
  • Chapter 3

  • Animation
  • bouncing pixel on black
  • bouncing sprite on black
  • bouncing sprite on fancy background
  • multiple bouncing sprites
  • Chapter 4

  • i/o
  • keyboard
  • mouse
  • joystick

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

  • Collision detection
  • rectangles only
  • Colour management
  • colour cycling
  • reserved colours for common elements
  • dynamic colours for various parts of a game

  • Timing a game, and game design
  • * separating drawing from logic *
  • the PC timer
  • too slow
  • too fast
  • Chapter 6

  • Games
  • Break Out
  • simple animation
  • collision detection
  • player control
  • Introduction . Chapter 1 . Chapter 2 . Chapter 2.1 . Chapter 3 . Chapter 4 . Chapter 5 . Chapter 6

    Copyright 1998 (c), Alex Russell, All rights reserved Last Updated Aug 2002