|
|
Ones and zeros First of all if you want to be able to program games, you'll have to learn how to tell the computer what you want it to do. All the computer really understands is 1's and 0's. I found this concept hard to grasp at first, let me try to clarify. A computer works with electricity right, so that means you have little electric shocks traveling through the computer turning things on and off. Therefore, the computer understands that when there is electricity it should turn something on (1) and when there is no electricity the thing should be off (0). This is the best way to imagine it, now to correct what I said, let me say that a zero (off) does not really mean that there is absolutely no electricity, it actually represent low voltage, and a one represents high voltage, but we don't need to go into that for now as long as we've understood the concept of on and off.
Communicating with the computer So do we have to write everything in ones and zeros?! Because that'd be insane... No we don't, that's why we have programming languages! Since it's very very hard to understand anything with ones and zeros, we have developed layers over the ones and zeros. These layers make things much easier and these layers are the programming languages we use. When we use programming languages we would normally write things like: "If this variable reaches this number then it's time to perform this function. If that function fails, then we need to close the application", That's all nice and easily understandable, but the computer turns our nicely written code in English into a bunch of 1's and 0's. So for example if I write some code that looks like this: -
In reality, the computer would turn that piece of "understandable code" to something like : "10010010 10010111 01010001 01010100 10101010 10010101 01011011 00100101 01101010 11010100 11010010 10011010 10110010 10101010 01001010 10010101 00100101 01010101 01010010 01010101 10010110 10100100 10101001 10010010 10100101 01001010 01010101 01011011 00100101 01101010 01001010 11010010 10011010 10110010 10101010 01001010 10010101 00100101 01010101 01010010 01010100 10010110 10100100 10101001 10010010 01010101 01010010 01010101 10010110 10100100 10101001". Talk about hard to understand. It's a good thing we never have to deal with something like that, also take note that I'm extremely simplifying things and in reality, we would probably end up with much more complexity then just 1's and 0's. So we need a way to turn our "understandable code" to "un-understandable code" so that the computer can understand it. How do we do that? Well, we use a program called a compiler. You can get free compilers over the internet or you can buy commercially available ones. I suggest you buy a Microsoft compiler, because they are probably the best and most commonly used, though Microsoft compilers are used for Windows applications only. To make progams for other operating systems you'll need a different compiler. You will write all your code inside a compiler window, just like you would write a report inside Microsoft Word. After you've written your code, you tell the compiler to start compiling (how you do this is compiler dependant). After the compiler finishes compiling your code, you will have an executable file as long as everything went well. Now let me tell you, writing code is no walk in the park. It makes you crazy, it's addictive, it's a challenge, it gives you white hair, it shortens your sane life period, and best of all, it works. Once you start coding thigs start to make more sense, you can relate EVERYTHING in this universe to code, it's great!
Which language should I use? Now as there are many real world languages used to communicate with human beings, there are a whole bunch of different languages you can use to communicate with the computer. Different languages have different advantages. The most common computer programming language used to write games is "C++" (C Plus Plus). C++ is an amazing language! You can do anything with it, and it's not the hardest language to learn either. There are of course alternatives to C++ that are easier to learn, but not as robust. For example "Visual Basic" (VB), Delphi, and Java. A new addition to the group of programming languages is "C#" (C Sharp). C# is easier to learn then C++ and it's almost as fast. You can pretty much make the same application in C# as you could in C++ in less time. But of course like all languages, C# also has its problems, as does C++, VB, Delphi, or any other language you come across. The bottom line is that which language to use depends on what you want to make. Most of game development happens with C++ though, so learning that is a must if you want to get into hardcore game development (i.e. make console games, and big PC games). You yourself have to try a few out and decide on which one you're most comfortable with. Take note however that there is such a thing as a high level language and a low level language, Most everyone uses high level languages like C++ and Java (there are more). A high level language is more understandable to us then a low level one. For example take this low level piece of code:
Now that hardly makes any sense to me (someone who actually wrote it). That's written in a language called assembly. Assembly is very low level, and each instruction transforms directly into computer understandable code, it's mostly used for intense optimizations and it won't do anyone any harm to know a little of it just incase. Anyway, if we were to make the exact same program in a language such as C++ it would look like this
See. The C++ version is much shorter and is understandable to a certain extent. All it says is: While the number inside "variable" is less then 10, add 1 to "variable". The exact same thing is done using the low level code above, but it's less obvious. I guess you can describe programming as a logical systematic sequence of events. Everything seems to work like they naturally would. If you wanted to move a chess piece two squares in front all you would do is change the y position of the chess piece to the current y position plus 2 right?...WRONG! This is where there is a big difference between a human moving a chess piece and a computer moving a chess piece. If you wanted the computer to move a chess piece 2 squares in front it would look something like this.
Now while that may not be exactly what happens, I'm just trying to show you that you have to think deeper then how you think normally, remember that the computer knows nothing. Always keep that in mind.
Can I use all the above to make games now? To put it simply, no. While a programming language is good at using the power of a CPU to accomplish tasks, it's pretty crappy at getting the best out of your graphics card, and lets face it, today's beautiful games would not be possible without complete control over our high tech graphics cards, and to get that kind of control you need to use something like a programming language add on. An application programming interface (API) is what we need. More specifically, a Graphics API is what we need. The two most popular graphics APIs used today are called Direct3D and OpenGL. Now to program games you will also need a way to gather input, so we'll need an input API (DirectInput comes to mind), and then we'd also need some music, and a few APIs for audio would be DirectMusic, DirectSound and FMOD. You must be wondering what's with all this "Direct" business? If you must know, our friends over at Microsoft have an API suite. That is a bunch of APIs that can do everything, the API suite has been given the name "DirectX". The APIs present in DirectX are Direct3D (for graphics), DirectInput (for input), DirectMusic (for audio), DirectSound (for more music) DirectPlay (for networking). So there you have it. Everything you really need is inside DirectX. The reason you need these extra APIs is so that you can communicate directly with the hardware so that you can get the most out of it. So, I suggest you learn C++ first. Remember that something like this takes quite a while to get a firm grasp of, so please be patient, once you are used to C++ then do what you want. Please do no start learning DirectX or OpenGL until you are very comfortable with C++ (or any language you want to use). After you learn your language, it's time to download an API and get to work, I suggest you get the DirectX Software Developers Kit (SDK) since it gives you everything you need and all for free. It's a big download (around 200 megs) but it's worth it. So all in all you'll need the following:-
So are we done now? Of course we're not done yet, you have a very long way to go. Now that you know C++ and have a good grasp of programming in general, it's time to learn how to use the APIs, now if you have gone with DirectX then you can start learning how to use it right on this site in the tutorials section. But if you've gone with something else, like maybe OpenGL, then you can start learning it from other sites like nehe.gamedev.net. I suggest you hit the "links" section on this site and check out all the links I've mentioned over there. You should be able to find a lot of helpful stuff to get you started. Let me tell you that this is not going to be any joy ride at the beginning. The beginning is where you'll find out if game development is for you or it you can't cope wit it. If after a year or so, you still find yourself reading game development forums and drinking 10 liters of coffee a day to stay awake so that you can fix a certain problem with your code then you, my friend, have found your passion.
Done That's all you really need to know to get started. Of course all this will take a long time to accomplish. Also I haven't said anything about the artsy side of game development, or the maagement side. This article is for if you want to get into programming. If you are more interested in art/music then I suggest you either start drawing or making some tunes. That sounds pretty straight forward to me. Also keep in mind that just by reading this article you will not be able to make a game. To make a game takes months of practicing and reading. Sometimes even years, especially for those people that are just starting out. Just make sure you practice practice read read. Either way. Good Luck. |
|