DEV Community

Roman Shapiro
Roman Shapiro

Posted on

MonoGame - A Game Engine for Those Who Love Reinventing the Wheel

Introduction

When creating a new game, one of the very first questions is choosing a game engine.

The main candidates everyone knows about are Unity, Unreal Engine, and Godot.

However, besides them, there are quite a few second-tier engines that few people know about.

One of them is MonoGame, which is exactly what I want to talk about in this article. I will briefly go over its history, discuss whether it is worth choosing, and share a couple of useful links.

History

The C# programming language was created by Microsoft in 2002. Microsoft positioned it as a general-purpose language, so they developed a number of technologies and libraries demonstrating its use in different fields.

One of these libraries was XNA, released in 2006. It was based on DirectX 9 and allowed developers to create games for the Microsoft ecosystem of that time, namely Windows, Xbox, and Windows Phone.

XNA immediately gained considerable popularity within the gamedev community, which naturally wanted their games to run on other devices and operating systems as well.

MonoGame was the answer to those demands. It aimed to be fully API-compatible with XNA while also running on Android, iPhone, Linux, and so on.

In 2013, Microsoft discontinued XNA support. As a result, MonoGame eventually had to expand to Microsoft platforms as well.

MonoGame Today

At the moment, MonoGame more or less implements the XNA4 specification.

In other words, it is essentially an abstraction layer over gaming hardware, providing fairly low-level access to graphics, audio, mouse, keyboard, gamepad, and so on.

At the same time, it also contains some higher-level functionality:

  • A linear algebra and 3D geometry library. Matrices, vectors, rays, transformations, and so on. There are many methods for 3D graphics, such as creating perspective and orthographic projection matrices. There are also bounding boxes, bounding spheres, and much more.
  • SpriteBatch, or the ultimate tool for working with 2D graphics. In particular, it allows rendering text.
  • An audio library.
  • Content Pipeline, a framework for processing assets and converting them into a format suitable for runtime use. It is a fairly controversial feature. Personally, I am not a fan of it and see nothing wrong with loading assets in their raw form.
  • A simple 3D model library. It has two major problems: a hard dependency on the Content Pipeline (meaning models cannot be created dynamically at runtime through code) and the lack of animation support. That is why I do not use it either.
  • Several simple shaders for 3D graphics. For example, BasicEffect, which implements lighting using the Blinn-Phong model, and SkinnedEffect, which does the same while supporting skeletal animation. Incidentally, the demo at the beginning of this article is built on top of these shaders. It is worth noting that they only support directional lights. Point lights and spot lights are unfortunately not supported.

Why Choose It?

The meme is almost true. Though it is probably worth clarifying that this mostly applies to very simple 2D games.

In the general case, however, it must be admitted that if maximum development efficiency is your goal, I would recommend using Unity or Unreal.

But if efficiency is not the top priority and you mainly want to enjoy the development process, then MonoGame is worth choosing for several reasons.

First, love for C#. Yes, Unity supports it too, but Unity uses its own framework that traditionally supported older versions of the language and runtime. MonoGame, on the other hand, works on top of the official modern Microsoft .NET ecosystem.

Second, appreciation for open source and permissive licenses.

Third, if you have a certain mindset often described as "think in code." If you dislike the designer-centric approach represented by Unity, Unreal, and Godot, and instead prefer the "bare" game loop approach offered by MonoGame.

Finally, if you enjoy digging into technical details and reinventing the wheel. Yes, there are many libraries built for MonoGame (the author of this article developed some of them). However, you are unlikely to find every piece of functionality your game needs. Most likely, you will either have to create your own libraries or extend existing ones.

Useful Links

Official MonoGame Site

Make sure to visit the Showcase page in order to learn about some well-known titles that were developed with XNA/MonoGame(i.e. Terraria and Stardew Valley)

FNA - Another XNA Implementation

Top comments (0)