Ask Slashdot: Best Way to Learn C# For Game Programming? 254
An anonymous reader writes So I, like many people, want to make my own game. Outside of MATLAB, Visual Basic, and LabVIEW I have no real programming experience. I initially started with Ruby, but after doing my homework decided that if I ever wanted to progress to a game that required some power, I would basically need to learn some form of C anyway. Further digging has led me to C#. The other parts of game design and theory I have covered: I have ~8 years of CAD modeling experience including Maya and Blender; I have a semiprofessional sound studio, an idie album on iTunes, and am adept at creating sound effects/music in a wide variety of programs; I'm familiar with the setbacks and frustration involved with game development — I beta tested DotA for 9ish years; I already have my game idea down on paper (RTS), including growth tables, unit types, unit states, story-lines, etc. I've been planning this out for a year or two; I will be doing this on my own time, by myself, and am prepared for it to take a couple years to finish. The reason for listing that stuff out, is that I want people to understand that I know what I'm getting myself in to, and I'm not trying to put out a not-so-subtle "help me make a game for free lol" type of post. With all of that said, where is a good place to start (i.e., recommended books) for learning C# for game programming? I am familiar with object oriented programming, so that's a little bit of help. I'm not necessarily looking for the syntax (that part is just memorization), but more for the methodology involved. If anyone also has any suggestions for other books or information that deal with game development, I would love to hear that too. I know enough to understand that I really don't know anything, but have a good foundation to build on.
Head First C# (Score:5, Interesting)
Warning: this is blatantly self-promotional. It's also a pretty good answer to the question, I think, so hopefully I won't get violently modded down.
It sounds like you're exactly who Jenny Greene and I wrote Head First C# [oreilly.com] for. I played around with a lot of different ways to teach both C# language and core object oriented programming and computer science concepts, and I found that building games was easily the most satisfying way to do it.
The only way to really learn a language is writing a lot of code, and one of the biggest challenges I had putting the book together was coming up with many different projects. The answer was games: a card games, a turn-based game, arcade games -- it turns out that building a game is a great way to keep readers motivated, especially when they're learning new concepts. I've had a lot of really positive feedback from first-time programmers who found it really satisfying to get through the book, and especially building the final project (a retro Space Invaders game).
You can download a free PDF of the first three chapters of Head First C# from the O'Reilly page [oreilly.com] and see if you like it.
C#? (Score:5, Interesting)
Why C#? Develop your game in C++ using OpenGL ES for rendering. Your code will compile as-is for iOS, Android, Windows, OSX, and others. You will only need a couple hundred lines of native code (java for Android, Objective C for iOS, etc) to handle events and pass execution into your C++ code. My game engine runs on all the above platforms and 99.9% of my code is shared across all of them.
Also, these days many, many developers simply use an existing game engine and only bother with the high level code specific to their game. Mundane stuff like the low level rendering, Audio APIs (which unlike OpenGL ES, differ quite a bit from one platform to another), physics, etc, is ground that's been treaded several thousand times nowadays, and most game developers leave that stuff to the experts in the various fields to handle the nitty gritty. Optimization of those routines is usually where the "expert" part comes into play.
I work with a game designer / artist who implements all the high level game stuff in Lua, and my engine takes care of all the aforementioned "boring" stuff, freeing him up to actually develop games, and not worry about crap like polygon tessellation algorithms and tons of other very boring stuff that would just be a waste of his time.
Choose another language (Score:5, Interesting)
I love C#. I program in it every day. It's plenty fast, and it's a great language.
However, there are two reasons I would suggest looking to another language.
First, the hottest market for gaming right now is mobile. While it's possible to compile C# for iPhone or Android using Xamarin (along with Windows and OS X), it's not exactly a native experience.
Second, C# (like O-C, C++, etc.) is a general programming language -- it's not in any way specific to the domain of game programming. So, while it's *possible* to design complex games in any modern language, you're probably going to spend *way* too much time dealing with silly stuff like tracking graphics resources and animation loops and simulated physics. You'll have a higher chance of success if you use a language and platform that is more game-specific out of the box.
I would suggest looking into Swift -- it'll give you access to the lucrative iOS market, it's C-like, and it has features that are game-specific. Sure, it's a new language it doesn't compile to Android, but by all accounts it looks like a great language with first-class support for gaming, so you can focus less on infrastructure code and more on the game.
Another option would be HTML5. Depending what sort of game you're looking to build, Javascript and HTML5 may be just the ticket, and there are a number of libraries that can abstract away browser differences and assist with the plumbing needed to make a game run.
Start with the engine (Score:2, Interesting)
Pick an engine you want to use first, then pick a language to learn that is used by that engine. Very few games now are written purely in a native language with no supporting engine, so pick a modern game engine that will do a lot of the hard, low level work for you. Then, learn the language that is used for interacting with the desired engine. For example, if you wanted to use the Unity engine, then you would basic learn C#. If you wanted to use CryENGINE, then you would learn C++ and Lua scripting. If you wanted to use the Unreal4 engine, then you would learn blueprint visual scripting and C++.
Once you know the engine and language you need to use, then pick up a book, take a course, etc... There are lots of ways to learn a language, but the most important thing is to practice, especially in the environment and engine that you plan to use. Each of the engines have extensive documentation on how to program for their engine and interact with the game assets.
Re:It's too slow. (Score:4, Interesting)
Build a simple first game ! (Score:5, Interesting)
The reason for listing that stuff out, is that I want people to understand that I know what I'm getting myself in to, and I'm not trying to put out a not-so-subtle "help me make a game for free lol" type of post
I'm sorry, but your long list of "I did this and that" means only that you are a gamer with a few artistic skills, it has absolutely no value for game programming !
During my 18 years of game programming, I met a lot of people that had "wonderful" ideas (it's funny how everybody has a dream game), but no skill to realize them.
They always boasted about the fact that their idea was great, but their project never got released.
Writing a game requires the following skills:
1) technical skill: coding
2) art skill: graphics/animation and sound/music
3) gameplay skill: making the game enjoyable
4) story telling: making a coherent game's universe
In my life, I never met a single person with all of these skills, at a decent level.
The most talented ones had only 2 skills.
Firstly, before coding your dream game, try to write a very simple game. It will show you where you'll need help.
If you are a beginner, you won't be able to code Starcraft.
Try something related to your project, so you can increase your knowledge.
Secondly, since most of the CPU power is spent on display and AI, you'll need to learn:
1) how to optimize the display.
Since the whole screen needs to be redrawn very frequently, you have to learn techniques to render fast.
There are tons of techniques in 2D and 3D.
2) AI algorithms, most notably path-finding algorithms if you want to program a RTS.
Thirdly, try to build a prototype in one month.
If you are able to build it in one month, you'll probably be able to work on your project during several months.
It will also show that you don't lose yourself on details (non-professionals tend to waste their time on small details, thus the final goal disappears).
If you are unable to build it in one month, it means that your project is not well defined, probably too ambitious or completely unrealizable.
Fourthly, I would recommend to build a motivated team around your game.
This is a virtuous circle: when your motivation will decrease, they'll encourage you and when they'll get demotivated, you'll encourage them.
Nowadays, I believe that it's impossible to write a game alone, unless your game is very simple.
Find people who believe in your project and who may help you.