Creating a solution template

I’ve been using MG for a couple of months now, and I realised that there are a few classes (like content managers, game state managers, input managers and so on) that are the same, or almost the same, for every new project I build. The Game1 class also looks pretty much the same in all of my projects, with a state machine, standardized draw loop etc.

Obviously copying them each time to a new project is a waste of time, so I was wondering whether there is any possibility to create a project template that I could re-use every time, just like other in-built MG templates. Do you guys have any solution to this problem? I was thinking about just having a base project that I would load and modify every time I start working on a new game, but changing the namespace label is a bit of a hassle in VS…

Yes, it’s called building a, wait for it… Game Engine!

MonoGame is a framework.

In your user directory look in a folder like

\<user>\Documents\Visual Studio 2017\Templates\ProjectTemplates\Visual C#\MonoGame

I guess it should work, if you just copy and edit one of the zip files…

2 Likes

I agree with this but creating a single DLL or a library to copy to a folder is way less effort… all you need is a single using and it’s in there…

Yeah, but would that give me the possibility to edit all these files independently within the solution? That’s my problem:

On one hand much of the code for these base files (GameObject, DrawableObject, ContentHandler etc. etc.) will be the same, so I would like to have them created by default when I make a new solution (just like the Program.cs or Game1.cs files are created). But I also want to retain the possibility to modify them within the solution to allow for new functionality. So I don’t think creating like an external library that I will reference to is what I’m looking for here (though I might be wrong, mind that I’m a total noob at this).

What do you think?

2 Likes

External libraries deal with the issues of extensibility and customizability via virtual methods, composition, interfaces and events. It takes some practice to get good at it, but since you know your code base and your needs, this could be an opportunity for you to learn about library development.

1 Like

Hmm… I get what you mean - I definitely would like to learn about that, and I’ll look into it in my spare time. On the other hand though, aquila non captat muscas, and I think with the size of projects I’m working on right now, getting into stuff like that would be a bit of an overkill (though it’s probably never too early to learn useful stuff).

I think for now I will try to clean up my base classes a bit, and go with what @Kwyrky suggested, to try and create a template for my projects. If my code base gets too bloated, I might actually end up creating an external library. Bless you all for your help, brethren. I shan’t forget it.