MonoGame: Getting Started with NuGet

Introduction

I am using the following software to write the article.  If yours differs your experience may be radically different; be warned.

  • Visual Studio Ultimate 2013 Update 2 (12.0.30501.00)
  • Windows 7 SP1
  • Firefox 30

Installing via NuGet

NuGet is (from http://docs.nuget.org/)  “a Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects that use the .NET Framework.”  NuGet is available for Visual Studio 2010 and above, with some limitations.  More information is available in the NuGet FAQ.

It really is quite nifty and a great way to resolve dependencies, as long as you’re aware of how to use it.  In our case we’re going to be installing MonoGame v3.2.2 through the Package Manager Console.  As always, step by step, it goes like this.

First, open Visual Studio 2013.

NuGetInstallationStep1Second, click on Tools, then look for NuGet Package Manager about halfway down the menu, then click on Package Manager Console, as highlighted in the next screenshot.

NuGetInstallationStep2This will open the Package Manager Console in your lower window section, as seen highlighted in red below.

NuGetInstallationStep3The first thing we want to do is find the MonoGame package.  To do so, click into the Package Manager Console and type the following command:

get-package -remote -filter monogame

A listing of known NuGet packages which have the word “monogame” in their description is returned, as seen in the next screenshot.

NuGetInstallationStep4What is the difference between MonoGame, MonoGame-Portable, and MonoGame.Binaries?  Well, MonoGame.Binaries is actually a dependency of MonoGame; as for MonoGame-Portal we’ll let the author answer that question over at StackOverflow.

We want MonoGame, v3.2.2 in this case. Before we can retrieve the package we need to open a solution for it to reside in.  Either open an existing solution, or create a new Console Application project.

NuGetInstallationStep5Click into the Package Manager Console and enter the following command to retrieve and install it.

install-package MonoGame

This will retrieve the latest version of MonoGame available via the NuGet system.  It takes a bit of time for the MonoGame team to package new versions and release them on NuGet so this may not always be the latest version, but it should be.

NuGetInstallationStep6If you’re prompted to overwrite a file and you created a new project for this installation, choose Yes.  Otherwise you’ll need to make the decision yourself.

At this point your project is prepared to use MonoGame.

Personally, I prefer the Visual Studio installation method.  It’s more permanent and feels more complete.

Next is a classic “Hello, World!”

 

Posted in Games, Programming | Leave a comment

MonoGame: Getting Started

Introduction

So I’ve decided on using MonoGame and am going to be writing articles as I go about learning to use it myself.  This will be the first article.

I am using the following software to write the article.  If yours differs your experience may be radically different; be warned.

  • Visual Studio Ultimate 2013 Update 2 (12.0.30501.00)
  • Windows 7 SP1
  • Firefox 30
  • MonoGame v3.2

The first thing to do is to install MonoGame.  There are two ways to get MonoGame into a project; either by downloading the Visual Studio installer or by using NuGet.

Downloading the Visual Studio Installer

Visit http://www.monogame.net.

The MonoGame HomepageClick on the Downloads link in the upper right corner.

MonoGame DownloadsClick on the latest version available to you.  In my case, at this time, that’s v3.2.

MonoGameDownloadsVersionThere will be two options available for downloading, MonoGame 3.2 for Visual Studio (local mirror) and MonoGame 3.2 on GitHub.  Click on the MonoGame 3.2 for Visual Studio link and wait for the download to finish.

Where your file downloads and saves files is dependent upon your specific operating system and browser.  For me, with Firefox 30, the file saved to my user specific Downloads folder.

When you execute the installer you’ll most probably encounter a UAC prompt, asking if you’re sure you want to allow the application from an unknown publisher to make changes to your computer.  Choose yes when prompted.  (No screenshot because I haven’t a clue as to how to take a screenshot of a UAC prompt.  Try it.)

MonoGameInstallationStep1Click Next.

MonoGameInstallationStep2My recommendation is to leave everything that’s checked, checked.  The size of the installation is miniscule compared to modern hard drives, and it’s often easier to ignore something than to rerun an installer and install it properly.

Click Install.

MonoGameInstallationStep3The installer will process the installation.

MonoGameInstallationStep4And will prompt you when finished.  Click Finish.

Now, open up Visual Studio 2013.

Click File, New, then Project.

VisualStudioVerificationStep1The MonoGame installer creates a new series of project templates.  They can be found under Templates,

VisualStudioVerificationStep2 Visual C#,

VisualStudioVerificationStep3MonoGame.

VisualStudioVerificationStep4If you see the MonoGame subsection of the Visual C# subsection, you have successfully installed MonoGame v3.2.  Next up we’ll show how to install via NuGet, followed by the classic “Hello, World!” tutorial.

 

Posted in Games, Programming | Leave a comment

Tag into the ASP.NET Validation JavaScript

This was a neat trick I picked up earlier today.  I had a blocking div that I was throwing up in order to prevent multiple clicks of a button, but found that method lacking once a validation error occurred.  I began to look into how you can check page validity using your own JavaScript and stumbled across this StackOverflow question:  Can I run some custom script after ASP.NET client side page validation occurs.

The first solution is to trigger the validation yourself, which is a valid option, but it’s the second solution by Yuny Rozhovetskiy which I loved — tag into the execution itself with the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
var originalValidationFunction =Page_ClientValidate;
     if(originalValidationFunction && typeof(originalValidationFunction)=="function")
     {
          Page_ClientValidate=function(validationGroup)
          {
                 originalValidationFunction(validationGroup);
                 if(!Page_IsValid)
                 {
                       // your code here
                      alert("oops!");
                 }
          };
     }
Posted in Programming | Leave a comment

Game Development with SlimDX (Packt Publishing)

Not a half bad book, ~130 pp, gets you up to speed on SlimDX quickly and with very little fanfare.  If you can’t make it through this book, you should probably give up the idea of developing a game. :-)

(SlimDX is a .NET wrapper around the DirectX functionality and is meant to be used from a managed language.)

http://www.amazon.com/Game-Development-SlimDX-Michael-Fontanini/dp/1782167382/ref=sr_1_1?ie=UTF8&qid=1403796216&sr=8-1&keywords=slimdx

Posted in General | Leave a comment

.NET Native Compiler (C#)

Here’s an interesting article from Visual Studio magazine about the .NET native compiler:  http://visualstudiomagazine.com/articles/2014/04/03/more-power-and-faster-development-with-dot-net-native.aspx

I’m curious as to why they chose to compile C# specifically and not IL in general (two stage compilation) and how performance will actually equate once memory management is figured in.  I don’t think it will equal C++ in power 100%, but I do believe it will help to bridge the performance gap between C# and C++.

 

Posted in Programming | Leave a comment