Windows 8 Game Development using C#, XNA and MonoGame 3.0: Building a Shooter Game Walkthrough – Part 1: Overview, Installation, MonoGame 3.0 Project Creation

Windows 8 Game Development using C#, XNA and MonoGame 3.0: Building a Shooter Game Walkthrough – Part 1: Overview, Installation, MonoGame 3.0 Project Creation

Rate This
  • Comments 24

Overview

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:

  • OpenTK - a low-level C# library that wraps OpenGL, OpenCL and OpenAL for 3D graphics.
  • SharpDX - an open-source implementation of the full DirectX API for .NET which allows for development of high performance games, 2D and 3D graphics rendering, and real-time sound
  • Lidgren.Network - a networking library for .NET framework which uses an UDP socket to provide an API for connecting a client to a server, as well as, reading and sending messages

     

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:

  1. Install Microsoft Windows 8.
  2. Install Games for Windows
  3. Install Windows Phone 8 SDK or Visual Studio 2010 Express for Windows Phone

    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.

    1. Visual Studio 2010 Express for Windows Phone: http://go.microsoft.com/fwlink/?LinkId=258412
  4. Install Visual Studio 2012 for Windows 8
    1. Visual Studio 2012 Express: http://bit.ly/QvLWLX

      OR

    2. Visual Studio 2012 Pro/Premium/Ultimate: Use DreamSpark, MSDN or your licensed copy
  5. Install MonoGame 3.0 binaries, templates, and dependencies with Windows Installer:

    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.

  6. Optional: Install GitHub

    If you want to review the MonoGame Source Code or contribute code to the MonoGame project.

    1. Create a Git Account: https://github.com/
    2. Install the GitHub Windows Client: http://windows.github.com/

 

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. **

  • Now we need to ensure that the Solution has the correct references to the MonoGame Framework and its dependencies. Right click on your solution in the Visual Studio Solution Explorer and select Add, Existing Project.

    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.

Leave a Comment
  • Please add 5 and 4 and type the answer here:
  • Post
  • 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

  • Hi C:

    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

    http://www.appshah.com/

  • 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=2.4.2.0, 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)

  • Jared Poche: The install files have been updated since the writing of this tutorial.  Have you tried: The 3.01 Build-> monogame.codeplex.com/.../102870 or the latest 3.2 Development Build-> build.monogame.net/.../Windows

    I would uninstall and ensure that I am installing one of the above.  On my Win8.1 machine I have now, I run the aforementioned 3.2 Build.  Also the MonoGame binaries have been added to NuGet as another option for you.  

  • games apps its the future for normal user gamming

    <a href="iphoneapplicationdeveloper.co.uk/">london iPhone app developers</a>

Page 2 of 2 (24 items) 12