Windows 8, XNA and MonoGame – Part 1, Overview
|Games are likely some of the most popular apps on Windows 8 and you are in a great position to take advantage of this huge opportunity. How huge? The Windows Store Blog sums it up well:
This is a 3 part series. You can reach the other posts in this series here:
|Casual game developers have been using XNA since 2004 to easily create games for Windows, XBox and most recently Windows Phone. XNA is a .NET framework for game development providing a content pipeline and game asset load functionality, animation, math, sound and user input tracking via gamepad, mouse, keyboard and touch with game logic organized in a straightforward game loop architecture. Game development is not trivial and XNA was a level up for a great number of students and developers who wanted to learn how to create games. XNA along with Visual Studio made it as easy as File –> New –> XNA Game Studio Project and you were off and gunning.|
Since Windows 8 is built on the strong foundation of Windows 7, any app built for Windows will run in the Windows 8 desktop environment. This includes apps based on XNA, Win32, .NET, WPF, Silverlight, etc.
Windows 8 also introduces a new type of app called a Modern UI Style App for developers that wish to make their app available in the Windows 8 Store, for free or for sale. Using Visual Studio 2012, you have a language choice of C++, XAML with C#, VB or C++, or HTML5/JS to create a Metro Style App.
Using the XNA Framework is not a choice for building a Metro Style App. Official Microsoft guidance on game development is documented here. The recommended way to build highly immersive games on Windows 8 is to use HTML5/JS, XAML/C#, XAML/VB or C++ and DirectX, all great choices. But if you have been developing with XNA and have an existing code base, your only option it would seem is running as a desktop app.
This is where MonoGame comes in…
MonoGame is an Open Source implementation of the Microsoft XNA 4 Framework. The goal is to allow XNA developers on Windows & Windows Phone to port their games to the iOS, Android, Mac OS X, Linux with both PlayStation Suite and Windows 8 support currently under development.
MonoGame provides a cross platform XNA Framework implementation for XNA developers who want to take their code to non-Microsoft platforms as well as the ability, thanks to Tom Spillman and James Ford of SickHeadGames, Dean Ellis and several other talented developers, to target Windows 8. Using MonoGame for Windows 8 you can take your XNA code and with a recompile and some additional platformisms create a Metro Style App worthy of the Windows 8 store.
MonoGame is still under development and so any use of it should come with a note of advice to stay on top of that effort. Also as game developers we should always be looking at expanding our game development skills on Windows using HTML5, XAML and DirectX in order to get the most out of the platform. But given that so many developers have XNA games, MonoGame for Windows 8 is a viable migration solution in the near term.
How MonoGame Works
MonoGame is a recreation of the XNA Namespace Hierarchy and Class Structure. If you dig into the source code of MonoGame, you will find that platform specific code is encapsulated within a #pragma compiler directive. Different directives are used for different platforms and can be controlled through BUILD rules. Here is a snippet from the ContentTypeReader class that shows the use of both the WinRT and Android #pragmas:
In order to provide a complete implementation of XNA on Windows 8, MonoGame leverages SharpDX , an open-source project delivering the full DirectX API for managed code (.NET) and Windows 8 (WinRT). SharpDX is an open-source project, free of charge available under the following MIT License.
Generation App: Getting You There
We are here to help you get your app on Windows. Here is how you can gain an advantage and stand out from the crowd through the programs we’re offering:
- Design Consultation
- Technical Consultation
- Online training and tips from insiders
In the part 2 of this of this series I will detail how to get started using MonoGame to port an existing XNA game to Windows 8.