My bachelor's thesis on 2D game engine development with MonoGame

Hello everyone,

I’ve decided to finish my CS degree and used my 2D video game engine as a bachelor’s thesis topic.
Not sure if it’s going to be useful for anyone, but I still thought it might be worth sharing even if only one ​person benefits from it somehow.
Please note that I’m a beginner in the video game development domain, so there might be (actually, I’m pretty sure there are) inaccuracies in the text, and also I’m pretty sure I’m not doing everything the best possible way, but this is where I am in my learning curve. I will try to keep it up-to-date as I gain more experience and also the engine is still very young, and lots of things will be added and changed.
Not much to see here for experienced folks, but beginners might find some useful bits in it.

Anyway, you’ll find the PDF here:

8 Likes

I played your game, read your thesis and checked a bit of your source code, and I want to thank you for it !
I’m a student hobbyist, and the information you gave where really informative (especially the source code for me). It give me a new point of view on how to implement things,especially UI and scene (I never tough of using a HashSet to store the scenes, I was stuck with an old implementation of mine…)

Here is a bit of my (small) knowledge, hoping it will help you like your code helped me :
You can use extension method to add method to existing type.

For instance in your MathUtil class, you have some methods like :

internal static Vector2 CalculateGridCoordintes(Vector2 position)
{
	return new Vector2(/* bla bla bla*/);
}

and you call them like that : MathUtil.CalculateGridCoordintes(someVector2)
Extension method have a sweeter syntax : someVector2.CalculateGridCoordintes()

To transform this method in an extension method, just add the static keyword before the Vector2 argument. The MathUtil class also need to be static, so you end up with somethings like that :

public static class MathUtil
{
	internal static Vector2 CalculateGridCoordintes(static Vector2 position)
    {
		return new Vector2(/* bla bla bla*/);
	}
}

It won’t change the code that much, but now you are aware that extension method exist :slight_smile:

1 Like

I love extension methods and typically do this often; however, it’s worth noting that when you do this, you can pollute the functionality of those classes.

In this particular case, it might actually not make sense for CalculateGridCoordinates to become a part of Vector2. Even if it’s super convenient :slight_smile:

This can be mitigated by keeping things in namespaces if you tend to keep your classes small (so you don’t need to use all the namespaces), but it’s something to consider.

Again, I like extension methods, but just something to be cautious of.

2 Likes

Thank you, I’m very happy to hear that you liked it!
Thanks for the heads-up regarding extension methods, I’m actually using them for other classes, but it did not occur to me to use them with the Vector2, although it would definitely make sense in some more places :slight_smile:

1 Like