Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
If you've been programming games for any reasonable amount of time, you've probably learned that at the end of the day, the really hard part of the job has nothing to do with illumination models, doppler shift, file formats, or frame rates, as the majority of game development books on the shelves would have you believe. These days, it's more or less evident that everyone knows everything. Gone are the days where game development gurus separated themselves from the common folk with their in-depth understanding of VGA registers or their ability to write an 8-bit mixer in 4K of code. Nowadays, impossibly fast hardware accelerators and monolithic APIs that do everything short of opening your mail pretty much have the technical details covered. No, what really make the creation of a phenomenal game difficult are the characters, the plot, and the suspension of disbelief.
Until Microsoft releases "DirectStoryline"—which probably won't be long, considering the amount of artificial intelligence driving DirectMusic—the true challenge will be immersing players in settings and worlds that exert a genuine sense of atmosphere and organic life. The floor should creak and groan when players walk across aging hardwood. The bowels of a ship should be alive with scurrying rats and the echoey drip-drop sounds of leaky pipes. Characters should converse and interact with both the player and one another in ways that suggest a substantial set of gears is turning inside their heads. In a nutshell, a world without compellingly animated detail and believable responsiveness won't be suitable for the games of today and tomorrow.
The problem, as the first chapter of this book will explain, is that the only solution to this problem directly offered by languages like C and C++ is to clump the code for implementing a peripheral character's quirky attitude together with code you use to multiply matrices and sort vertex lists. In other words, you're forced to write all of your game—from the low-level details to the high-level logic—in the same place. This is an illogical grouping and one that leads to all sorts of hazards and inconveniences.
And let's not forget the modding community. Every day it seems that players expect more flexibility and expansion capabilities from their games. Few PC titles last long on the shelves if a community of rabid, photosensitive code junkies can't tear it open and rewire its guts. The problem is, you can't just pop up an Open File dialog box and let the player chose a DLL or other dynamically linked solution, because doing so opens you up to all sorts of security holes. What if a malicious mod author decides that the penalty for taking a rocket blast to the gut is a freshly reformatted hard drive? Because of this, despite their power and speed, DLLs aren't necessarily the ideal solution.
This is where the book you're currently reading comes into play. As you'll soon find out, a solution that allows you to both easily script and control your in-game entities and environments, as well as give players the ability to write mods and extensions, can only really come in the form of a custom-designed language whose programs can run within an embeddable execution environment inside the game engine. This is scripting.
If that last paragraph seemed like a mouthful, don't worry. This book is like an elevator that truly starts from the bottom floor, containing everything you need to step out onto the roof and enjoy the view when you're finished. But as a mentally unstable associate of mine is often heard to say, "The devil is in the details." It's not enough to simply know what scripting is all about; in order to really make something happen, you need to know everything. From the upper echelons of the compiler, all the way down to the darkest corners of the virtual machine, you need to know what goes where, and most importantly, why. That's what this book aims to do. If you start at the beginning and follow along with me until the end, you should pick up everything you need to genuinely understand what's going on.