How to Program Games
"How to Program Games" is a set of tutorials which I am writing.
They will guide you through the development of various games,
showing how new features are added at each stage, and hopefully
demonstrating good design technique.
The tutorials are aimed at both complete newcomers to game
programming and people who have written a few games but would be
interested in seeing my methods anyway. Veterans may also find something
of interest -- I find that examining other people's techniques is often
Structure of tutorials
Each tutorial is arranged as a set of chapters, each having its own
directory which contains the source for the game at that stage and a file
called `tutorial.txt', which points out things in the source that have
changed since the previous chapter. The emphasis is really on the source
itself, which is well commented; the text files serve mainly to point you
to the interesting parts of the source code at the moment.
The tutorials are written primarily for people using Allegro,
and ought to work on any platform it supports. I started
writing them using djgpp, but now I'm using Linux; they should
definitely work on both of these platforms. I am including
djgpp and Linux makefiles. These should convert easily
I expect they also
work with Windows gcc ports, as far as these are supported by
I have not included
makefiles or native build
djgpp (v2.01) and Allegro
(v3.0). With the advent of WinAlleg they might be easily portable to
Windows -- I've heard good rumours about WinAlleg (though I'm not in a
position to use it myself).
Of course, the concepts should themselves port easily to other sane
compilers. The code written is not likely to be djgpp-specific.
In the list below, each tutorial has two links -- one to a ZIP file
containing the whole tutorial and one to the readme.txt file for that
tutorial, in case you want more information before downloading it.
The numbers in brackets are the sizes of the downloads.
Sorry, only one so far!
- "How to Program Pong"
- This shows how to develop Pong, demonstrating the basic principles
of game programming, such as the main game loop, input,
processing, and output. It contains seven chapters, but is not
yet finished. It is written in a very modular manner,
as are all of these tutorials. Don't skip this one just because
Pong is a simple game; the techniques it introduces are
fundamental to game programming and the other tutorials will use
them without explaining them in this level of detail.
Plans for future tutorials
This list is by no means final; it could easily change. There are a
large number of concepts that need covering in this series, and I of
course want to cover those concepts in as few games as possible ;).
I won't list all the concepts, since there are so many of them;
instead I'll list some possible games, and the major concepts they
would cover. Overlap is unavoidable, of course; the tutorials will be
ordered to some extent and overlapping topics will be covered in most
depth in the first tutorial that covers them.
- So far this covers the basic game structure, modularity, simple
display techniques, abstract input and modular processing of game
objects. It will/may eventually also cover (at a basic level)
sprites, sounds, music, computer-controlled characters with very
basic AI, use of timers to regulate the game speed, and simple
front ends. The more complicated topics will of course be
explained clearly and in detail, and they'll come up again in
later tutorials for more development.
- This would be a fairly simple action game. The core would be much
the same as Pong's core. It would introduce polar coordinates,
tracking objects in game units rather than pixels, acceleration,
double buffering and possibly dirty rectangles or page flipping.
It might also introduce gravity, as an added twist. Asteroids
with gravity would be interesting...
- A strategy game
- This would introduce tile maps, point-and-click mouse control,
simple AI for moving player-controlled units (e.g. basic
- A platform game
- This would also use tile maps, with a more versatile display
engine to make them scroll smoothly. There'd be gravity, of