Tricks of the Windows Game Programming Gurus:Introduction

All ITKnowledge Source Code Search Tips Advanced Search |

| Tricks of the Windows Game Programming Gurus by Andre LaMothe Sams, Macmillan Computer Publishing ISBN: 0672313618 Pub Date: 09/27/99

Search this book:

Table of Contents

## Introduction

> “Dead or alive, you’re coming with me.”

> —Robocop

A long time ago, in a galaxy far, far, away, I wrote a book about game programming called Tricks of the Game Programming Gurus. For me, it was an opportunity to create something that I had always wanted—a book that taught the reader how to make games. Anyway, it’s been a few years and I’m a little older and wiser, and I have definitely learned a lot of tricks <BG>. This book is going to continue where the old book left off. I’m going to cover every major topic in game programming that I can fit within the binding of this bad boy!

However, as usual, I’m not going to assume that you are already a master programmer or that you even know how to make games. This book is for beginners as well as advanced game programmers. Nonetheless, the tempo is going to be fierce, so don’t blink!

Today is probably the coolest time in history to be in the game business. I mean, we now have the technology to create games that do look real! Imagine what will come next? But all this technology isn’t easy to understand or trivial—it takes hard work. These days the bar has definitely been raised on the skill set needed to make games. But if you’re reading this, you are probably one of those people who like a challenge, right? Well, you came to right place, because when you’re done with this book you will be able to create a full 3D, texture-mapped, professionally lit video game for the PC. Moreover, you will understand the underlying principles of artificial intelligence, physics modeling, game algorithms, 2D/3D graphics, and be able to use 3D hardware today and in the future.

What You’re Going to Learn

In this book you’re going to learn about 100 teraquads of information! I’m going to fill your neural net so full of information that you might have synaptic leakage! Seriously, though, this volume covers all the elements necessary to create a Windows 9X/NT-based game for the PC:

  • Win32 programming
  • DirectX Foundation
  • 2D graphics and algorithms
  • Game programming techniques and data structures
  • Multithreaded programming
  • Artificial intelligence
  • Physics modeling
  • Using 3D acceleration hardware (on the CD)

And more…

This book is primarily about game programming. There are two cyber-books on the CD that cover Direct3D Immediate mode and General 3D.

What You Need to Know

This book assumes that you can program. You are going to be fairly lost if you can’t write C code. However, the book uses some C++—enough to make a C coder just a little uneasy. But I will warn you if I’m doing anything weird. Also, there’s a decent C++ primer in Appendix D, so check it out if you need a crash course. Basically, C++ is only needed here and there for examples when using DirectX.

Nevertheless, I’ve decided that I’m going to use C++ a little more on this book because there are so many things in game programming that are object-oriented, and it’s sacrilege to force them to be C-like structures. Bottom line—if you can program in C, you should be fine. If you program in C/C++, you shouldn’t trip out at all.

Everyone knows that a computer program is nothing more than logic and math. Well, 3D video games put the emphasis on the math part! 3D graphics is all math. Luckily for us, it’s cool math! (Yes, math can be cool.) About the only thing you need to know is basic algebra and geometry. The vector and matrix stuff I will teach you along the way. Heck, if you can add, subtract, multiply, and divide, you will be able to understand 90 percent of what’s going even though you may not be able to rederive it. As long as you can use the code, that’s all the matters. (Well, that and if 7 of 9 is on Voyager tonight.)

That’s really all you need to know. Of course, you’d better call all your friends and tell them that they won’t see you for about two years, because you’re going to be a little busy. But just think of all the movies you’ll get to rent when you’re done with your training!

How This Book Is Organized

Tricks of the Windows Game Programming Gurus is divided into four parts, covering 14 chapters and six appendixes.

Part I: Windows Programming Foundations

Chapter 1 | Journey into the Abyss
Chapter 2 | The Windows Programming Model
Chapter 3 | Advanced Windows Programming
Chapter 4 | Windows GDI, Controls, and Last-Minute Gift Ideas

Part II: DirectX and 2D Fundamentals

Chapter 5 | DirectX Fundamentals and the Dreaded COM
Chapter 6 | First Contact: DirectDraw
Chapter 7 | Advanced DirectDraw and Bitmapped Graphics
Chapter 8 | Vector Rasterization and 2D Transformations
Chapter 9 | Uplinking with DirectInput and Force Feedback
Chapter 10 | Sounding Off with DirectSound and DirectMusic

Part III: Hardcore Game Programming

Chapter 11 | Algorithms, Data Structures, Memory Management, and Multithreading
Chapter 12 | Making Silicon Think with Artificial Intelligence
Chapter 13 | Playing God: Basic Physics Modeling
Chapter 14 | Putting It All Together: You Got Game!

Part IV: Appendixes

Appendix A | What’s on the CD
Appendix B | Installing DirectX and Using the C/C++ Compiler
Appendix C | Math and Trigonometry Review
Appendix D | C++ Primer
Appendix E | Game Programming Resources
Appendix F | ASCII Tables

Installing the CD-ROM

The CD-ROM contains all the source, executables, sample programs, stock art, 3D modelers, sound effects, and bonus technical articles that make up the book. Here’s the directory structure:

    CD-DRIVE:\

    T3DGAME\

    SOURCE\

                  T3DCHAP01\

                  T3DCHAP02\

                       .

                       .

                  T3DCHAP14\

    APPLICATIONS\

    ARTWORK\

                   BITMAPS\

                   MODELS\

    SOUND\

                  WAVES\

                  MIDI\

    DIRECTX\

    GAMES\

    GOODIES\

    ARTICLES\

    ONLINEBOOKS\

    ENGINES\

Each main directory contains specific data that you’ll need. Here’s a more detailed breakdown:

  `T3DGAME`—The root directory that contains all other directories. Be sure to read the `README.TXT` within it for any last-minute changes.
  `SOURCE`—Contains all the source directories for the book, in chapter order. Simply drag the entire `SOURCE\` directory to your hard drive and work from there.
  `DEMOS`—Contains demo programs that various companies have so graciously allowed me to place on the CD.
  `ARTWORK`—Contains stock artwork that you may use royalty-free in your games.
  `SOUND`—Contains stock sound effects and music that you may use royalty-free in your games.
  `DIRECTX`—Contains the latest version of the DirectX SDK.
  `GAMES`—Contains a number of 2D and 3D shareware games that I think are cool!
  `ARTICLES`—Contains articles written by various experts in the field of game programming for your edification.
  `ONLINEBOOKS`—Contains online digital books covering Direct3D Immediate mode and general 3D graphics.
  `ENGINES`—Contains evaluation copies of various 3D engines.

There isn’t any general installation program for the CD because there are so many different types of programs and data. I’ll leave the installation to you. However, in most cases, you’ll simply copy the `SOURCE\` directory to your hard drive and work within it. As for the other programs and data, you’ll probably install them as you need them.

Installing DirectX

About the only important part of the CD that you must install is the DirectX SDK and Run-Time files. The installation program is located within the `DIRECTX\` directory, along with a `README.TXT` file explaining any last-minute changes.

> Note: You must install DirectX 6.0 SDK or better to work with this CD. If you’re not sure that you have the latest files on your system, run the installation and it will tell you.

Compiling the Programs

I wrote the code for this book with Microsoft Visual C++ 5.0/6.0. However, in most cases the programs will work with any Win32-compliant compiler. Nevertheless, I suggest Microsoft VC++ because it works the best for this type of work.

If you are unfamiliar with your compiler’s IDE, you are going to be wildly lost compiling Windows programs. Please take the time to learn your way around the compiler, and at least know how to compile a “Hello World” console program or something similar before you dive into compiling the programs.

To compile Windows Win32 `.EXE` programs, all you need to do is set the target of your program project to Win32 `.EXE` and compile. However, to create DirectX programs, you must include the DirectX import libraries in your project. You may think that you can simply add the DirectX libraries to your `include` path, but that won’t work! Save yourself a headache and include the DirectX `.LIB` files in your project or workspace manually. You can find the `.LIB` files in the `LIB\` directory, right under the main DirectX SDK directory that you installed under. That way there won’t be any linker confusion. In most cases, you’ll need the following:

`DDRAW.LIB` | DirectDraw import library
`DINPUT.LIB` | DirectInput import library
`DSOUND.LIB` | DirectSound import library
`DMUSIC.LIB` | DirectMusic import library
`DSOUND3D.LIB` | DirectSound3D import library
`D3DIM.LIB` | Direct3D Immediate Mode import library
`DXGUID.LIB` | DirectX GUID library
`WINMM.LIB` | Windows Multimedia Extensions

I’ll go into more detail on these files when you actually start working with them, but at least keep them in mind when you start getting “unresolved symbol” errors from your linker. I don’t want any emails on this subject from rookies!

In addition to the DirectX `.LIB` files, you must include the DirectX `.H` header files in your header search path, so keep that in mind. Also, be sure to make the DirectX SDK directories first in the search path list, because many C++ compilers contain old versions of DirectX and the old headers might be found in the compiler’s own `INCLUDE\`, which is wrong. The proper place is the DirectX SDK `include` directory, which is located in the main installation directory of the DirectX SDK in `INCLUDE\`.

Finally, if you use Borland products, make sure that you use the Borland versions of the DirectX `.LIB` files. They can be found in the `BORLAND\` directory of the DirectX SDK installation.

Table of Contents

Copyright © Macmillan Computer Publishing, Inc.

Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.