How to Make Video Games, Part 4: The Hacker
In the last two hubs I talked about the Visionary and the Career Gamer. As I mentioned in those hubs, the Visionary tends to approach game design from the artist's perspective and is strongly motivated by the desire to share his or her vision, while the Career Gamer tends to approach game design from the gamer's perspective and is strongly motivated by the desire to share his or her love of games.
The Hacker, in contrast, approaches game design from the scientist's or engineer's perspective, and is strongly motivated by his or her personal desire to understand and master the technology behind the games. In many ways, in spite of their proverbial tendency toward social awkwardness, the Hacker is the backbone of the game industry. Without the curious and disciplined mind of the Hacker, there would be no video game industry.
The Hacker's Path
Hacker's generally get into the game industry by writing software; often, by writing their own game engine, but usually by writing various sorts of tools to assist others with various sorts of problems: file import and export scripts to expand the range of file types that an application supports; file management systems to streamline development pipelines; file converters to convert older versions of files to newer versions or to convert files between different applications; script extenders to expand the functionality of an application's native scripting capabilities; and simple 'unofficial' bug fixes and patches are all common fare of the hacker's trade.
Obviously, to do this sort of thing, you need to know a lot about computers and programming. You will probably want to go to school and get a proper computer science degree for this sort of thing if you can, but you can learn a lot of this stuff on your own if you're smart and dedicated. Ultimately, what matters is ability; a working graphics renderer is going to be a lot more impressive to a potential employer than a diploma with no real-world experience. If you can have both, go for it, but if you can't afford the education force yourself to sit down and program every day; preferably on something that solves a real-world problem for somebody, even if it's just an obscure indie or modding tool.
Understand Your Hardware
You don't need to be a hardware expert to get into game programming. A lot of the architectural details are hidden behind APIs (application programming interfaces) and it is generally no longer necessary for a game developer to know about specific device drivers or concern themselves overmuch with how the hardware is translating the code at the machine level. Having said that, there is a lot to be gained by having an thorough understanding of how computers work, and what a programming language actually does behind the scenes.
At a minimum, you're going to need a thorough understanding of how computers model and manage data, if not on specific platforms, at least in general. Games require intense optimization, and you're not going to do a good job optimizing code if you don't understand what your code is doing at the hardware level. Programmers working on business applications don't generally need to concern themselves with framerates; for game programmers, the data types you choose can make or break your game.
Additionally, you need to know various sorts of platform-related details, like what shader models various graphics cards support, what version of DirectX or OpenGL is supported on popular platforms, and how to write code that works on both 32-bit and 64-bit systems. If you're writing software for consoles or handheld devices or smart phones, you need to understand what the technological capabilities and limitations are. If you're writing network code, you need to understand how networks work, at least in theory. In short, you have to love (or at least be able to sustain an interest in) hardware. (You can usually identify a Hacker in the wild by the modifications they have made to their 'rig'.)
Intro to Game Programming
Learn the Right Programming Languages
When it comes to programming languages, your choice is simple: C++. C++ is the industry standard. I wouldn't want to hand in a resume that didn't indicate that I knew my way around C++ source code. That doesn't mean it's the only language you'll want (or need) to learn, but it is pretty much a given that if you're working with game code you're going to be working with C++. Even if the engine itself isn't written in C++, it's going to need to interface with popular middleware (graphics, physics, sound, etc.) and operating system APIs that do use it. C++ would be a good language to learn even if you didn't end up using it because it is so versatile and allows you to code close to the hardware. If you can master C++ programming you will have no difficulty learning other languages.
Of course, other languages may be important on specific projects, or when working for specific studios. It's probably not a bad idea to learn some assembly because it can be useful for optimizing performance, which is important for games. Other languages, like C, C#, and Java, are also useful in certain circumstances and will certainly look good on a resume. Most game engines also have their own scripting language, or use a language like Lua or Python for scripting, but this is something you can probably learn best while working on a specific project. The other language that can be useful is XML, which is used for a variety of things these days. For example, the user interface for Oblivion and Fallout 3 uses XML files.
One other area you may want to invest some time in is shader programming. Shaders are used to change the way object surfaces reflect light in games. They can be used for things like motion blur, depth of view, ambient occlusion, god rays, and numerous other effects. Because these effects are very important to modern games, it is probably a good idea to explore them.
Books on DirectX and OpenGL
Master the APIs
In addition to understanding computer architecture and programming, you need to acquire a basic understanding of a platform's operating system and the various 3rd party APIs you'll be using. Most game development is still done on Windows platforms, so Windows programming and DirectX are probably good things to school yourself in. Depending on your target platform, you may be required to learn about other operating systems as well (such as iOS), but that's the sort of thing you can worry about when you get there. (Console games are completely independent platforms; you can't really learn how to use them any other way than on the job or after you qualify for a license to develop on those platforms.)
The old dilemma about whether to learn DirectX or OpenGL is really moot: learn both. Both APIs are widely used in the industry and learning both will teach you more about graphics programming since they approach things from slightly different perspectives. DirectX is probably more popular in the game industry, so you might want to make that your first choice but it shouldn't be considered an either/or dilemma.
You will also likely need to learn other APIs, like a physics or audio API. Most programmers in the industry are fairly specialized, and this tendency is only going to grow stronger so you might want to specialize in one area (eg. physics, audio, graphics, UI, etc.) and make that the centerpiece of your portfolio.
Math and Physics Homework
Learn Math and Physics
If you're going to go into game programming, you're going to need to know some math. Mathematics is ultimately a model of the world, and since your job as a game programmer is to model the world (or alternate worlds) it pays to invest as much time as you can in the discipline. The specific subjects you should study depends somewhat on the field of specialization you plan on going into, but here are a few pointers:
- Discrete mathematics is the cornerstone of computer science and is applicable to every field but plays a special role in AI. Discrete will teach you a lot about how computers work and will make it easier for you to adapt your abstract concepts to work in practical environments.
- Game theory and probability theory can also be useful to game design, especially for designing strategy games, and can have useful applications in designing AI and for implementing game mechanics.
- If you plan on going into graphics design, of course, you will need a solid understanding of trigonometry and linear algebra which will teach you about the vectors, matrices, and quaternions you need to use to perform calculations in 3D space.
- Last but not least, if you plan on doing any physics programming, you will need to know calculus.
Really, any math that you take is going to help you as a programmer, not only because it will open up new possibilities in game design, but because it will train your mind to work in a way that is conducive to solving programming problems.
For a really good discussion of what it takes to be a game programmer, read this great post: A Guide to Higher Education for Aspiring Game Programmers.
Aside: Master Your Math Anxiety
If you're one of those people that shudders at the thought of doing math then game programming is probably not the way to go; however, if you are serious about programming and just need to overcome a block when it comes to doing math and physics, here are a couple of things you can do:
- First of all, realize that your current aversion to math is based on bad experiences you've had in the past that you've had no control over (typically in a school setting); now that you are in a position to take an active role in your own math education, you can...
- Set your own pace and your own learning objectives. Decide what the single thing you need to learn now to progress in math is; don't pick a whole discipline like trig or calculus, chunk it down to something small and simple. If that means that the next thing you need to learn is how to simplify radicals, then that's what you need to learn no matter what your long term objectives are. Take it one step at a time.
- Realize that all math is is a set of rules (theoretical math is more than this, but you don't need to be a theoretician). All you are doing is learning what the rules are, why they work, and how to apply them. Math is no different from learning a programming language; in fact, they are so similar that if you can learn how to program in C++ there is no reason you can't learn linear algebra. Just think of it as a syntax you need to master made up of keywords and operators that have specific meanings and variables that you supply.
- Practice what you learn. Do it until you know it so well that you don't even have to think about it when you do it, the same way you probably don't have to think about how to add or subtract. Don't move on until the new concept is a regular part of your math vocabulary.
- Learn one new concept a week and practice the syntax for at least an hour until you can do it through muscle memory, like long division. You'd be surprised how quickly you can progress: if you learned one concept a week for a year, that's 52 math concepts (take a couple weeks off: shoot for 50 :) ). How long do you think it will take you to learn the math you need at this rate? A couple of years? If you think of 'learning math' as one huge chore that just has to get done you will never even get started, chunk it down to bite-sized pieces so that you can control your own experience.
Study Source Code
Another thing I recommend doing is studying the source code of professionally made games. Many publishers have released the source code to their games online for you to learn from and tinker with. Id has a great reputation in this regard, and will be releasing the code for Doom 3 in the immediate future. (Note that these are just the source code and don't include any of the assets, so you can't play them as is; they are for educational use only.)
Here's a list of popular source codes to get you started:
- DOOM (pdf)
- Hexen/Heretic
- Quake
- Duke Nukem
- Penumbra
Some publishers (like Valve) give you access to portions of the source code through their SDKs (software development kits) so that you can mod their games. These SDKs are not open source, but give you an insight into how big, AAA games work under the hood. (You need to own a copy of the game to use the SDK.) Half-life 2, Portal, Left4Dead and other games all have SDKs.
Get Involved in Open Source Projects
If you want to learn real-world programming, of course, there is no better way to get started than by getting involved in an open source project. As I mentioned in the previous section, many game companies have released the source code to their games for others to learn from. Some of these code bases are being actively cultivated by open source programmers.
Here's a short list of a few interesting projects:
- List of open source video games at Wikipedia
- Chocolate Doom Doom source project
- Quark game editor for Quake and other related games
Other programmers are working on their own, independent projects and actively encourage other people to pitch in. Sourceforge is a great place to find projects that you might be interested in contributing to, but there are plenty of other ways to get involved.
Be Active on the Forums
The last thing you should do is be active on the forums. Asking and answering questions will teach you a lot about programming and will quickly dispel any illusions that you might have about knowing everything there is to know about game programming! Here are some popular forums you might want to check out:
The last two suggestions: getting involved in open source projects and being active on the forums, will go a long way toward helping Hackers break out of the shell that they sometimes find themselves in. In the next hub, we will leave behind these discussions about the industry and career paths and start looking at the game design process itself.
Additional Reading
For a look at the different types of game programmers, check out this article at Wikipedia.
Another great look at what it takes to be a game programmer: So You Want to Be a Game Programmer.