How to Learn XNA

How to Learn XNA

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.


Interested in other gamedev platforms? Check out our guides for learning Unity or Flash, too!

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.


Installing XNA

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

How to Learn XNA

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…


Learning C#

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.

How to Learn XNA
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!


XNA Books

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!).

How to Learn XNA

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:

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.


Make Games

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.


Huge thanks to Stephane Beniak and Michael Hoffman of NullCandy for their recommendations! Check out their XNA tutorials, and look out for some new tutorials from them here at Gamedevtuts+ soon.

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!

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • doug

    How about we make the best way to learn XNA through a series of awesome tutorials on here? Maybe start off with some simple 2d stuff then work into a 3d fps with multiplayer?

  • XPreNN

    Thank you soooo much for this! I had been looking for how to start with XNA again (I had used it once a couple of years ago, with a student license). I could not for the life of me figure out what I had to install, where to find it, or even if it was free or not! Such a relief to finally find this information.

    Thank you thank you thank you!

    • http://gamedev.tutsplus.com Michael James Williams
      Author

      Thanks! Yeah, it’s ridiculous how confusing Microsoft has made that.

  • Insanicae

    I looked up the C# 4.0 Pocket Reference on Amazon as i was curious. I´m currently studying C# starting my second semester in 2 weeks. So the Pocket Reference seemed like a nice little companion as i have a similar book for SQL databases.

    On Amazon though, there´s a C#5.0 Pocket reference out now, so any reason you´re pointing people towards the 4.0? Not a lot of new stuff or just personal preference?

    I didn´t get a chance to read up a lot on it as i was on my way out of the door. So before i place an order on both the XNA and the C# books, should i go with 4.0 or 5.0 if any?

    Ontopic though, i like this little “starter guide” and will definately be looking into the tutorials.

    • http://gamedev.tutsplus.com Michael James Williams
      Author

      I’m not sure whether C# 5.0 is supported by XNA yet – can any XNA experts clear this up?

      C# 4.0 should be fine if you’re following the guide, though; I think you need Visual Studio 2012 to use C# 5.0, but the official XNA download uses Visual Studio Express 2010.

      • Insanicae

        Thanks for the quick reply.

        I´ll go with C# 4.0 then. I know we´ll eventually go to VS2012 with school and all, but no details yet. And i heard a few friends about it too saying 4.0 should be just fine for my needs so far.

        (:

      • http://nullcandy.com Michael Hoffman

        You are correct. XNA 4.0 requires Visual Studio 2010, and will not work with Visual Studio 2012 or C# 5.

        The differences between C# 4 and C# 5 aren’t that major with regards to game programming. The biggest new feature in C# 5 is probably the await and async keywords, but asynchronous operations don’t arise that often in XNA.

  • King

    Awesome article, really helpful – thanks Michael.

    I too would love to see more XNA tutorials on here.

    • http://www.rcdmk.com RCDMK

      I second that.

      I would be very helpfull to have tutorials on XNA here. Specially a series, from beginner to advanced.

  • rinalds

    It would be great if you could do the somethiing similar for C++ oriented game development.

    • http://gamedev.tutsplus.com Michael James Williams
      Author

      We plan to cover every big game development platform eventually :)

      • rinalds

        Awesome! Looking forward to it!

  • Taylor

    I’m more into UDK myself, but this isn’t a bad article none the less. I’d like to see some UDK tutorials on here as I’m sure they would be rather popular.

  • http://www.mnuworld.com Anto Khan

    Great Article :) Nice Info :)

    Thanks

  • Paul

    I’ve been through a few of these books and a lot of the content has typos and holes when I tried to follow them

    • http://gamedev.tutsplus.com Michael James Williams
      Author

      Oh really? Which ones?

  • http://www.henryhoffman.com Henry Hoffman

    XNA isn’t being natively supported by Windows 8, and Windows Phone 8 is moving away from it too. After attending a Windows Phone developer conference, a Microsoft representative was very firm in his assertions that Microsoft were trying to put XNA behind them.

    I’d strongly recommend looking at alternatives sooner rather than later (though thanks for the great tutorial).

    • http://gamedev.tutsplus.com Michael James Williams
      Author

      I had heard that it wasn’t natively supported in Windows 8, but wasn’t aware of the Windows Phone situation. Interesting to hear that from the Microsoft rep, as well.

      Any idea what the situation is with Xbox?

      • http://www.henryhoffman.com Henry Hoffman

        I think with the aim to unify the platforms they’ll be aiming to fizzle it out long-term. I’m not sure what the replacement will be for Xbox – though there has been an interesting push for Unity across all Microsoft platforms. I’d be surprised if XNA wasn’t supported on the next generation of Xbox, though with their current stance portability will remain an issue.

        • http://gamedev.tutsplus.com Michael James Williams
          Author

          Interesting – thanks!

    • http://www.crazypointer.com/ Ricardo Amores Hernández

      MonoGame does support Windows8