XNA is a game development platform from Microsoft that can be used to create games for Windows, Xbox 360, and Windows Phone. In this article, we'll share books, tutorials, and suggestions for learning XNA as smoothly as possible.
What Is XNA?
XNA (originally "Xbox New Architecture", now simply "XNA's Not Acronymed") is a set of .NET-based game development tools, which run on Windows - sorry, Mac and Linux users. Games made with XNA can be run on Windows, Xbox 360, and Windows Phone 7, with other projects like MonoXNA and MonoGame attempting to bring the games to other platforms.
The XNA tools themselves are free, and for a yearly fee you can sell your games via Xbox Live Indie Games (assuming they pass peer review) and the Windows Phone 7 marketplace. (If you're a student, you can get a year's Xbox Live Indie Games membership for free.) Windows games built with XNA can be sold just like Windows games built with any other tools - there's no official marketplace for XNA games.
Since the XNA Framework is built on .NET, any .NET language can technically be used to make games with it - although only C# and Visual Basic.NET are officially supported.
The latest version of XNA, 4.0, was released in September 2010 with a refresh in October 2011, so it's fairly mature, and there are plenty of resources for it. There has been no announcement of version 5.0, so you needn't worry about learning XNA 4.0 only for your knowledge to become immediately obsolete.
As mentioned above, the XNA tools are only officially supported on Windows.
Rather confusingly, the official XNA site is the MDSN App Hub, whose Download page has a heavy Windows Phone focus -- it's not really clear what you need to download if you want to develop XNA games for Xbox or desktop.
However, it's actually simple: just download and install the Windows Phone SDK 7.1, which contains all the software and tools you need to develop with XNA for Windows Phone, Xbox, or desktop.
The download includes Visual Studio Express 2010, but if you already have a better version of Visual Studio 2010, you can download and install the XNA tools separately: XNA Game Studio 4.0 and XNA Game Studio 4.0 Refresh.
You might also want to buy an Xbox 360 controller for your PC for testing purposes, though of course this is optional.
The Official Tutorial
The MSDN App Hub has an introductory tutorial (part video, part written) that walks you through building a simple shooter game. It's about ninety minutes long, though you can expect to spend a few hours actually completing it yourself, and uses C#, which I'd recommend you pick as your XNA language even if you already know another .NET language.
Once you've completed it, try changing something: the artwork, the speed of the enemies, the frequency at which the enemies appear, the power of the bullets... You could even try making a boss that takes multiple hits! Digging in to the game like this will help you see what you understand and what you need to work on.
Other tutorials, articles, and source code samples are available in the App Hub content catalog. Again, it can be fun to just take something and dig into the code to see if you can change how it works, or add a new feature.
Supposedly, this tutorial is aimed at people who are complete beginners to game development, and doesn't require any former knowledge of programming. However, having followed it myself, I suspect that if you don't already have experience in C# (or a similar language like Java or AS3), you'll find it overwhelming.
So think of that tutorial as a test: if you feel that you didn't really understand what was going on, then don't fret -- it just means you need to learn to code...
If you want to make games with XNA, you will need to learn to program. Rather than trying to learn to program and learn XNA game development at the same time, it's easier to tackle programming on its own. Yes, that means building things that aren't games, but this will help you make games in the long run.
Head First C#
Head First C# is a great book to start with. It has a fun approach; the authors actually use lessons learned from game designers to structure the book.
If you're hungry for more after this, get a copy of Essential C# 4.0. What you'll learn from Head First C# is probably enough to let you jump in to XNA game development; Essential C# will help you sharpen the saw and become a better C# programmer.
It's handy to have a reference to look up unfamiliar keywords (like a dictionary for programmers). The MSDN C# reference is fine for this, but if you want something physical, get a copy of the C# 4.0 Pocket Reference.
Have a go at the official XNA tutorial again after you get to grips with C# -- it'll make so much more sense!
Okay, so you understand C# -- or at least you understand a similar programming language. Great! It's time to dive in to XNA and start making games.
There are two great choices for your first XNA book, and they both assume you already know C#. Pick the one whose approach you think you'll like best (or just get both!).
Learning XNA 4.0 is an introduction to XNA that takes a fairly theoretical approach. It teaches 2D game development and then 3D game development, in the context of building games. Part of the book is devoted to explaining how to export your games to Windows Phone 7 and Xbox.
XNA 4.0 Game Development by Example takes a more practical or functional approach, explaining XNA by showing you how to make four separate games. As well as teaching you new concepts, the book helps you practice making games.
If you want to go further after reading either of those, check out XNA Game Studio 4.0 Programming. It goes much deeper into XNA, and contains advanced material that you'll need to know if you want to be a serious XNA developer. Don't feel you need to rush to buy it, though; get comfortable with the basics, first.
Tutorials on the Web
There's no shortage of XNA tutorials online, but these sites offer the most comprehensive guides:
- RB Whitaker's XNA Tutorials: This site has a huge number of XNA tutorials, arranged by topic in a hierarchy -- so there's some structure to them, but you have a fair amount of choice regarding which order you do them in.
- Shawn Hargreaves' Blog: Shawn Hargreaves is one of the designers of XNA, so it's no surprise that he has a really deep understanding of the platform. Most - but not all - of his posts are tutorials. There's also a categorized list of posts.
- Riemer's 2D and 3D XNA Tutorials: Riemer has one series on making 2D shooters, and four series on making 3D games, split over 89 individual tutorials. As he puts it, "the major aim of these XNA tutorials is to produce nice-looking results within the shortest possible time."
- XNA Game Programming Adventures: This site has one short tutorial series on building a brick breaking game, aimed at beginners, and one huge series (over 30 parts long!) on building an RPG, aimed at more experienced developers.
- Catalin's Blog: Catalin Zima has some excellent tutorials on vertex textures, deferred rendering, and fur rendering in XNA.
Want even more? Check out Nelxon Studio's XNA Developer's Survival Kit 2, which lists a huge number of resources on all XNA topics.
If you need some reference material, check out the MSDN Library on XNA. For questions and answers, there's always the Game Development Stack Exchange -- take a look at the previously asked questions tagged XNA 4.0.
This is just a general tip: for your first game, don't make something complex like an MMO, or something that requires huge amounts of artwork and story like an RPG. Begin with something simple that you might be able to expand upon later. For example: a single button game like Canabalt could be extended to create a platformer; a Pong clone could be turned into a brick-breaking game with multiple levels; an avoider game could become a space invaders clone and then a full-blown shoot-'em-up.
Don't worry about learning advanced programming techniques quite yet, either; you'll have time to get to grips with design patterns and general code architecture later. Focus on finishing some games, even though your first ones will only be small.
If you have any suggestions for XNA learning resources that we've missed, please let us know in the comments. Don't forget to check out our other How to Learn guides as well!