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.
MonoGame is good, but due to its very limited 3D support, it only gets you so far. To make 3D games, you have to go extreme with DirectX, Unity 3D.....Unity3D has announced windows 8 support.
Looks awesome TEW, I'll be watching for part 2.
@Coder: the shooter tutorial is for a 2D game, and the point of this article series is (or appears to be) about the ability to use MonoGame to port a 2D game written in c# to android, ios, etc.
So I'm pretty sure this is true but I would just like clarification: Monogame can be used to make games for the Windows Store in a way that was similar to XNA except without the Content Pipeline. I was a big fan of XNA but unfortunately discovered it only about a year ago and I just started getting good with it. I was dissapointed to see it not incorporated into Windows 8 development. But MonoGame looks really cool. Thanks!
@Coder: did you check the project recently? 3D support was added in 2012.
@Jeff: I will cover how to leverage the Content Pipeline with MonoGame (the workaround) in Part 3 of this series.
@Coder: You are right Unity is the defacto standard for 3D gaming development, and I'm excited that they have announced Win 8 support and toolkit forthcoming. We will have having a Live Stream training on it in partnership with Unity once the Windows 8 support/SDK is launched. But you can get some pretty cool 3D games & graphics using XNA/MonoGame as well. Not Halo, but cool nonetheless
tpcmurray: You asked and you shall receive :) Part 2 was posted on Monday.
always an amusement absorbing your knowledge
Can I conclude, that I can continue with MonoGame with all the functionalities provided with XNA?
Original Bit: Yes you should be able to use most of the functionalities associated with XNA with MonoGame. Things like Content Pipeline are not yet available but are in the works to be added. See my Post 3 of this tutorial for how to leverage a Content Pipeline with MonoGame.
T E W - thank you for this detailed tutorial and the additional comments. I can use all this information.
points to an old Beta 3.0 version.
In order to install the latest stable MonoGame, perhaps it's better to use this link:
and follow the directions given in that page.
Thanks T E W for this tutorial walkthrough series. Good work.
I look forward to seeing more of this kind of step-by-step documentation on Windows 8 MonoGame development available in the near future.
I echo the sentiments of On-2012 and others ... This type of tutorial is just what developers need. Your presentations so far on this shooter game have been clear, concise and just what we need. I can't wait for Post 4 (hint hint).
Several months ago, when I was on Pluralsight, I learned of their MonoGame online course and started it but had to stop not too far in due to some illness and work pressures. By the time I could resume my PC (win7) had crashed and I've resurrected it by installing Win8. I also chose to only install VS2012 (along with my PhoneDev toolkits). I stumbled across your series of posts almost by accident last night and thought I'd start again with yours.
Since Post 4 isn't yet ready (or I can't find it) do you (or anyone else) know if the Pluralsight course applies equally to VS2010 and 2012? I seem to remember it saying something about it but I don't recall what it was. I know it old enough to require the manual installs of all of tools and libraries (the new v3 install is MUCH better).
how about, do not buy windows 8 or xbox 720, cont. with windows 7 and vs2010 and build great games for xbox 360.
Metro UI is like windows vista, it's to forget........
Well fernando, I'm going to guess that this blog post might not be for you. This blog is for folks who want to build cool games on Windows 8 using C# and XNA. Plus, I can still build for XBOX with this as well, so it's nothing but goodness.
I think that you should check out Scott Hanselman blog post on Windows 8: Who Moved My Cheese.