How This Book Is Organized
The book is organized into four parts:
- Game Programming Fundamentals (Chapters 1–4): Exposes some stuff that you’ll want in your game programming toolbox, like a good random-number generator. It also introduces the major components of games and how they interact. After you read the chapters in this part, you’ll have a good working knowledge of the real architecture that game developers use.
- Get Your Game Running (Chapters 8–9): It’s now time to learn how to get all of the main building blocks of your game together, including the initialization and shutdown code, the main loop, game actors, user interfaces, and input device code. You’ll find your first meaty game code examples. Often, many programming books just gloss over this stuff and jump right into the cool 3D code. But, in reality, this is the stuff you really need to know to create a successful game, no matter what type of game you want to build.
- Core Game Technologies (Chapters 10–18): The tougher code examples are in this section, such as 3D programming, scripting with Lua, game audio, physics, and AI programming.
- Advanced Topics and Bringing It All together (Chapters 19–24): In this section, you’ll find chapters on networking, programming with threads, creating tools in C#, and bringing all the code in the book together to make a little game.
You’ll also see some great debugging tricks and an entire chapter on how it feels to be there when you release a commercial game.
What You’ll Need
If you’re a programmer and you’ve had some game programming experience, you’ll be able to follow along nicely. Take a moment to flip through the pages, and you’ll see this book is written for programmers. Nonprogrammers could probably get something from the book, too, but there is more code in this book than noncode.
The code is written in C++, Lua, and C#. If you don’t know these languages, you’ll probably struggle a little with the code samples, but I’ll bet you can get enough from the comments and the explanations to get your money’s worth.
All of the code in this book works under Visual Studio 2010, or at least it did when it was copied into Microsoft Word, which is how Rez and I wrote the book. Apologies ahead of time for making no attempt whatsoever to make sure the code worked in other compilers like CodeWarrior or GNU C++. I hope you’ll forgive us. We figured our time would be better spent by covering as much technical ground as possible, instead of working on multicompiler–compatible code.
The Lua code was written using the Decoda IDE. Since Lua isn’t a compiled language, you don’t have to use any special editor; Notepad will work just fine. However, there is a DEPROJ file included with the Lua scripts so if you happen to use Decoda,
the project is all laid out for you.
The code in this book also has a heavy Windows bias. I’m a Windows programmer, and I was a DOS programmer before that. I’ve had some brief forays into UNIX on the Ultima Online server code, but I’m hardly an expert. Much of the code in this book assumes that you are using Windows, and I didn’t change the code to support cross-compiling into other operating systems for much the same reason as I chose a single compiler. It was simply better for me to cover lots of technical issues than for me to check my code under LINUX.
As far as graphics APIs are concerned, I assume you’ll use DirectX 11 or later. The code supports both Direct3D 9 and Direct3D 11, but only Direct3D 11 is covered in the book. I don’t have anything against OpenGL, of course, but I’m just not an expert in the nuances of it. Basically, if you have a good working knowledge of C++, C#, Windows, and a passing knowledge of DirectX, you’ll be fine. You don’t have to be godlike in your skill, but you should be pretty comfortable coding in these areas.
If you are a complete newbie and perhaps only know a little C++, don’t feel dejected and don’t return this book! I have a plan for you. Throughout this book, I’ll refer to other tomes of knowledge that helped me learn how to program. They can help you, too, and you can use them in conjunction with the humble collection of knowledge you hold in your hands. With a little concentration, you can bootstrap yourself into programming prowess. I learned more about programming in C++, DirectX, and Windows by looking at working code, of which there is plenty included in these pages for you to enjoy.