Why Learn to Program?

I can't count the number of times I talk to someone who wants to make video games, and the following conversation ensues:

Them: "I have this great idea for a game. It's going to change the world of gaming forever, and it is going to make me rich! I just don't know where to start. What do I need to do to make a game?"

Me: "Do you know how to program?"

Them: "No. Not really."

Ah. Stop right there. We've run into our first problem. How do you expect to be able to make a game if you don't know how to program?

OK, you're right—there is one possibility. You could become a game designer, find some underlings that know how to program, do the artwork, write the game music, and design the levels.

But let's be honest, game designers typically need a good understanding of all of the things that their team needs to do, including programming.

And besides, at some point, even if you are a game designer, you're going to need to be able to attract underlings to work for you. The best way to do this is to be able to show them some games that you have already created that are exciting and engaging—prove to them that you are actually a good game designer.

So we can see that if you really want to be able to make games, being able to program is an important first step.

I'll be honest with you: the first little while that you are learning to program can be a bit tedious and boring. The simple programs that we'll be creating at first will be very dull compared to the stuff you'll be making afterward. But it is an important step. You need to learn to walk before you can learn to run.

Computer games are really one of the few tests of a person's abilities in programming. It combines all of the major fields of computer science: basic programming, sophisticated data structures and algorithms, networking, GUI design, artificial intelligence, and computer graphics are all used. More than that, games often rely heavily on other fields as well, such as art, 3D modeling, animation, physics, storytelling, and even psychology.

Making games is not easy, but despite the challenge, it is fun and rewarding. There is nothing quite like the first time that you give a friend a game, and they want to keep playing it because they're enjoying it. (This won't necessarily happen the first time you give them a game to play, but trust me, it will come!)

Most people who view this crash course are probably doing it because they want to try their hand at making games. But video games aside, basic programming skills are useful in a wide variety of ways. If you know how to program, you will find ways to use it.

What is C#?

In this set of tutorials, we will go over the basics of the C# programming language. Video games and all computer programs, in general, are simply complicated sets of instructions that the computer follows.

Computers are extremely stupid, but they are also extremely good at following directions. You, as a programmer, will be able to create a set of directions that the computer can follow.

Computers, however, only understand instructions in binary, a language composed entirely of 1's and 0's. Once upon a time, people would program by writing out all of the 1's and 0's. (OK, technically, they didn't write it; they had a bunch of switches that they would turn on and off.) Of course, that is incredibly tedious and is no fun at all.

So people created programming languages where you can write computer instructions in a text-based format that resembles English. This kind of text-based human-readable format is called source code.

You then take that source code and give it to another program which basically translates your human-readable source code into something that the computer can understand and execute. This is sometimes called "compiled code", a "binary file", "executable code" or simply "an executable."

There are hundreds or even thousands of programming languages out there. Each looks a little different, and each is well suited for different things. These languages are not all that different from the many spoken languages in the world today. Some are similar, and some are extremely different from one another. Some are widely used, while others are only used by a small handful of people. Many good programmers know a wide variety of them.

Out of all of the possibilities, C# is one of the best. It is a very popular language. It provides a nice balance between what it can do and how easy it is to use. C# is part of the C/C++ family of languages, meaning that a lot of the syntax (the way you put commands together) is very similar to C, C++, and Java, all of which are very popular languages as well. After you go through this set of tutorials, you will likely be able to open up C, C++, and Java code and understand what is going on, for the most part. Likewise, if you already know one of those languages, learning C# will be a piece of cake. As far as most people using this guide are concerned, once you know C#, you will be able to move into making games with XNA.

About this Tutorial Set…

This set of tutorials is designed to teach you the basics of programming in C#. I expect that people will take anywhere from 10 to 100 hours to go through the entire thing, depending on how much programming you already know.

This guide is really just a crash course. Most students studying computer science at a college or university will spend two full semester-long classes going through these things.

Even when you have completed the entire crash course, there will still be much to learn about C# and programming in general.

The goal, though, is to give you enough information to start exploring on your own and, for many of you, move ahead into the game development tutorials. As you do so, don't be afraid to come back to these tutorials and review some of the principles discussed here.

You are about to begin an exciting journey into the world of programming!

What's Next?

We're ready to dive into the world of C# programming. Let's get started by installing Visual Studio, a free program that allows you to create C# code!