Converting a GameMaker: Studio project to MonoGame (Part 1)

I recently changed from using GM:S for a game I’m working on to using MonoGame. There are a few good reasons for doing this, mainly to do with low-level control, and some performance improvements. There are many good reasons not to do this. A few that spring to mind are:

  • You use GM:S for the drag-and-drop coding
  • You’re not familiar with object-oriented programming but are happy using GML
  • You like the large and active community of GM:S
  • You use some of the advanced features of GM:S, like In App Purchases or Advertising
  • (Perhaps most importantly) Everything is fine as it is in GM:S

With all that said, MonoGame is a great cross-platform library, and for much of what you’d want to do there is an easy one-to-one conversion into C# with MonoGame.

Things which will be more difficult to convert include Time Lines and Texture Pages. I shan’t go into much detail on these, but be aware for the latter that your performance could be significantly worse if you use lots of individual sprite files rather than unified sprite atlases.

I’m going to talk through a conversion process for the Tile Based Platformer project which comes with GM:S. Hopefully for other simple projects the conversion is just as easy.

I will assume you’re comfortable with C#, or at least object-oriented programming. I will also assume you know your way around GM:S. Finally I’m assuming you’re using Windows, though it shouldn’t be too hard to reinterpret this for other platforms.

You will need MonoGame installed, on top of Visual Studio. I had some trouble getting the templates to work in VS2015 Community, so perhaps it’s easier to use 2013.

Structure of the game
The Tile Based Platformer project contains a few different things we will need to translate. There are 6 animated sprites, 3 objects using these sprites, a ‘Background’ which contains tiles for the level, a ‘Room’ to hold all these things, and 3 Paths inside the room.
This project does not contain any shaders, sounds or text, so I won’t go into those in this post, though I may at some point in the future and it’s not hard to do.

Setting up the MonoGame Solution
Open up Visual Studio, and create a new solution using the “MonoGame Windows Project” template (in Templates->Visual C#->MonoGame). Call it something relevant like “Tile Based Platformer”.

You will see a few things in the solution already created for you:
We have a folder called Content, which is where we’ll store our sprites, as well as shaders and sounds if you have those. This contains a config file for the content builder, which you should just leave.
We also have two C# files: Game1, the main game class, and Program, which is the entry point for the application and just calls Game1.

Don’t worry about Properties or References for now.

“Game1” isn’t a useful class name, so rename the file “TileBasedPlatformer.cs” and change the class name and constructor from “Game1” to “TileBasedPlatformer”. Then go into Program.cs and replace “game = new Game1()” to “game = new TileBasedPlatformer()”. If you’re lucky, Visual Studio will do these steps for you when you rename the file.

Next, let’s add subfolders to Content (right click on Content, Add->New Folder) for Sprites, Rooms and Backgrounds.

Finally, add new classes for Room, Object and Path. Right-click on the project, and choose Add->New Item.

Make sure ‘Class’ is selected and and change the name to “Room.cs” etc. Your solution should now look like this:

If you hit Start, you should see an empty blue window.

Adding Content
Head back over to GM:S. We need to export our sprites to files we can use in MonoGame.
Double click on each sprite, click “Edit Sprite” and then File->Save as PNG File…
Navigate to your MonoGame solution’s Content/Sprites folder, and save it.

Now go back to Visual Studio, right click on the Sprites folder and choose Add->Existing Item. Browse to the Sprites folder, change the file type to All Files and add the sprite.

Now right-click on the sprite you’ve added, choose properties and change the build action to “Copy if newer”.

Repeat this process for each of the sprites.

We can do exactly the same thing for the background, but make sure you save it and import it in the Backgrounds folder.

The final bit of content we need is the tile information for the room. Right-click on the Rooms folder in the Solution Explorer, and Add->Existing Item. Now browse to the GM:S project’s folder (Probably called and then the subfolder rooms. Making sure you have it set to “All Files”, import the file called “”. This is just an xml file storing each tile.

The solution should now look like this:

In the next part of this series, we will write the code for Room.cs and Object.cs.

One thought on “Converting a GameMaker: Studio project to MonoGame (Part 1)

Leave a Reply

Your email address will not be published. Required fields are marked *