Casual game developers have been using XNA since 2004 for ease of create games for Windows, XBOX and most recently Windows Phone. XNA is a .NET framework for game development providing a content pipeline and load functionality for game asset, 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 undertaking and XNA was a great framework to start down the path for a great number of novice game developers and/or students and developers who wanted to learn how to create quality game applications. XNA along with Visual Studio made it as easy as File –> New –> XNA Game Studio Project and you were off and running.
MonoGame is an open source cross platform implementation of the XNA namespace and class model. The goal of MonoGame is to provide XNA developers with a framework to build applications that will run on Xbox 360, Windows, Windows 8, and Windows Phone while providing the ability to port the game using the same C #codebase to run natively on the iOS, Android, Mac OS X, and Linux platform with minimal effort. With these goals in mind, the MonoGame motto therefore is to "Write Once, Play Everywhere". The technologies that make the MonoGame API cross-platform power possible are:
The game you will be making in this walkthrough is using the MSDN Shooter tutorial. Shooter is a particular type of game with a set of well-defined limits around what it does when the user interacts with it. This tutorial is a good starting point for learning game development with XNA and publishing a game running on Windows 8 platform using XNA leveraging MonoGame. In addition to leveraging this technology for Windows 8, you can use the MonoGame technology for native cross-platform development with other mobile platforms.
Setting Up Your Development Environment
Before you can write games for Windows 8 using MonoGame, you mush setup your enviroment and your IDE to do so. I have outlined the steps below for getting your environment created. Please follow and perform the following steps in the order stated to successfully prepare your computer for XNA Development with MonoGame:
Why do I need Visual Studio 2010? There is a feature of XNA called the Content Pipeline, a pre-compiler step in the preparation of graphic and audio assets for use at runtime in XNA. This feature is not implemented in MonoGame. You can leverage VS 2010 or VS 2012 with the Windows Phone SDK installed to leverege the XNA Framework template to compile the graphics into the .xnb files to include in your Windows 8 project.
Leverage the new MonoGame 3.0 Windows Installer to install the MonoGame and SharpDX libraries needed to create an XNA 4.0 project for Windows 8. This will also install two MonoGame templates for use within Visual Studio to start an XNA/MonoGame project.
If you want to review the MonoGame Source Code or contribute code to the MonoGame project.
Create a MonoGame project
Windows 8 is designed to run on a variety of devices, including tablets and other devices that, through the aid of on-board sensors, know whether they are in landscape mode or portrait mode. XNA Game Studio 4.0 Refresh is a programming environment that allows you to use Visual Studio to create games for Windows Phone, Xbox 360, and Windows. XNA Game Studio includes the XNA Framework, a set of managed libraries designed for game development based on the Microsoft .NET Framework. In order to leverage the power of XNA for Windows 8 since it is not supported natively, we will leverage the MonoGame framework.
Step 1 - Create a MonoGame project and set references
Open Visual Studio 2012 and select New Project. Under Templates, select Visual C#, you should see the MonoGame project templates listed. Select the MonoGame Game (XAML). Name the project Win8ShooterGame and ensure that the option to Create directory for solution is checked/selected.
Figure 1 - Visual Studio with MonoGame Templates
Step 2 - Set a MonoGame references (Optional)
**Follow these Steps ONLY if you Installed MonoGame Directly from GitHub or have problems with Template pointing to correct MonoGame references. If you installed via the MonoGame Installer, please skip to Step 3. **
Figure 2 - Add Existing project to Solution
Browse to in Explorer to C:\Users\[you]\Documents\GitHub\MonoGame. Select the folder named MonoGame.Framework. In this folder, you will find the MonoGame Windows 8 CSPROJ project file in this directory: C:\Users\[you]\Documents\GitHub\MonoGame\MonoGame.Framework\MonoGame.Framework.Windows8.csproj. Select this project and click Open.
Figure 3 Add MonoGame Framework for Windows 8 project to Solution
Once the project has been added to the Visual Studio solution, right click on the MonoGame.Framework.Windows8 project, and select Clean. Then right click on the project again, and select Build. You may see a few warnings once you build the project, but that is okay.
Now select the Win8ShooterGame solution, select References, right click and select Add Reference. In the Reference Manager, we need to add the reference to the MonoGame.Framework into the Windows 8 project by selecting Solution and then Projects. Select the checkbox beside the MonoGame.Framework project. Click OK (Figure 4). Then again go back into Reference Manager and add the MonoGame Framework Dependencies by selecting Browse. Browse to location: C:\Users\[user]\Documents\GitHub\MonoGame\ThirdParty\Libs\SharpDX\Windows 8 Metro and select all of the .dll files within the folder.
Figure 4 Add MonoGame Framework and SharpDX reference
Finally, select the Win8ShooterGame and right click. Select Project Dependencies and select the checkbox next to MonoGame.Framework.Windows8. Click Okay and Rebuild the Entire Solution. You may get warnings, but if you have followed the steps correctly, there should be no errors.
Figure 5 Add MonoGame Framework Project Dependency
Step 3 - Test MonoGame Environment
Now, let's test to see if your MonoGame environment is set up correctly by running the application either via Local Device or and via the Windows Simulator. If your setup was successful, you will see the Cornflower Blue background commonly created by default with the XNA Framework projects.
You are now ready to start building your Windows 8 game. In Part 2 of this series, we will add the first asset to be used in your Windows 8 Game, a player object. The player which will be represented as a spaceship will be the primary source of control for the first player shooter game. In Part 2, we will create and build a player class object to represent the actions and properties associated with the spaceship for the game.
I get an error when opening the mono xml template in a new project: It says There is a missing project subtype: BC8A1FFA-BEE3-4634-8014-F334798102B3 is unsupported by this installation
The MonoGame team has release a new Windows installer. Please uninstall what you have and go to www.monogame.com/downloads to install the latest build.
How do you deal with the new Windows 8.1 resolution/window mode functionality? By default, Monogame seems to treat the snapped views as a 320px view regardless of the actual width of the window.
The installation of this beast is a nightmare. And I'm not a newbie talking. I've been developing games in AS3, XNA (the REAL XNA), and Java for 5 years and have created successful releases in less time tha I've spent f----- with this configuration. My advice: there are plenty of engines out there. find one that works.
Marc: Not really especially that since this article was written last year, all you have to do is run installer here: www.monogame.net/downloads or monogame.codeplex.com/.../102870
Amazing tutorial thanks for sharing it with us. For more details please visit
Getting error after error trying to just compile the basic game, all referencing SharpDX. I've resolved a few issues already, but now I've gotten the following:
Could not load file or assembly 'SharpDX, Version=18.104.22.168, Culture=neutral, PublicKeyToken=627a3d6d1956f55a' or one of its dependencies. The bound assembly has a version that is lower than that of the request. (Exception from HRESULT: 0x80132000)