How should I structure a Level/Scene System?

This is pretty much my first time creating a game using a framework instead of an engine like Unity or Unreal so I’m not very knowledgeable when it comes to structuring stuff. Currently I’m stuck on getting my head around how I should structure a level/scene system where I place all my GameObject’s.

I have a level class that’ll run through a list of GameObject’s and update/render them but when it comes to creating individual scenes, I’m just a little confused. I assume you create another class that’ll inherit from that Level class, and then write the code within that new class to add GameObject’s and stuff but that just doesn’t feel right to me. Likely cause I’m used to just dragging and drop GameObject’s into a “physical” scene. Is that the way I’m meant to do it or is there a more ideal way?


I am working on a game right now, structured in a way I find really nice…

I have a “level” class, which has a list of “rooms”, which each have a list of “layers”, which each have lists of game-objects, and a tile-grid…

Then I update and draw whichever rooms and layers correspond with my characters location…
(characer stores a current room and current layer index number)…

Not only is it simple programming, but it makes sense physically, which is easy on the brain.

1 Like

The nice thing about MonoGame is you can structure things however you want or need. The ideal way is the way that works best for your project. However, this can also be daunting.

If you’re making a 2D game and are looking for some way to place objects, I would highly recommend looking into Tiled, which is a general-purpose map editor with open formats.

It sounds like you are off to a good start, though I wouldn’t use inheritance to make levels. There’s lots of ways to do it but a good place to start is to write a function you can call for each level that creates a Level and adds GameObects to it and returns the Level.

The way I’m doing it is - I’m sure there are better ways, by the way - is by using a Scene + SceneManager class. Basically, in my game engine/framework project, all of the low-level stuff is taken care of and most of it is accessed through a global class, wherein everything is accessible anywhere. In there, I create an instance of the SceneManager class so it can be accessed anywhere. The SceneManager class takes a list of Scenes - which actually load in the maps - and initializes, loads/unloads, updates and draws all the scenes.

Additionally, I rename ‘Game1.cs’ to ‘Main.cs’ to know that that’s where I load everything in, update, etc. However, I don’t directly access the global SceneManager; instead, I have two classes, named ‘GameWorld.cs’ (for all the active game logic), and ‘MenuWorld.cs’ (for all the active menu logic). To create a new scene, I create a new class and inherit from ‘Scene.cs’ - which contains a field (which is a string) that allows you to name the scene, and then in ‘GameWorld.cs’, I write: Globals.SceneManager.Scenes.Add(“nameOfTheScene”);

Again, this is a rather verbose post, and the solution itself may not be that pretty, but it works.

1 Like