Room System

how can i make a room system to load / unload objects, switch between rooms and draw sprites?

I would think this is really just an issue of organizing your entities/actors/characters into folders/scenes/rooms (whatever you wanna call them).

I’m assuming we’re starting off with one big list of entities that you iterate over in your Draw and Update calls in your Game class or something.

So if you want to seperate your entities into rooms your Game class could instead have a list of rooms that each have their own list of entities and you would instead iterate over your rooms in the Game class.

This is the basic idea though, I think it’s difficult to give a solid answer to this question without knowing where you’re at.

when I was figuring out how to structure my project I took a lot of inspiration from other game engines (Unity/ Godot/ GameMaker). it was pretty useful just seeing in the files what actually was changing when I would make changes to a scene in Unity.

I’m just kinda learning as I go, but this is what I have so far.

Game => Locale (Scene Group) => Scenes (Entity Group) => Entities => Components

A scene loads stuff from it’s JSON file and keeps the entities generated in it’s own list so we can get rid of it when we’re done with that scene. I also have a “keep on load” scene (just like in Unity) for stuff that should persist between scenes/ rooms

Not sure this is the most efficient way to do it, but the way I do it is that each room/scene is a DrawableGameComponent; when I need to change the scene/room, I call a function which just disables the current one and toggles its visibility. And in turn, it enables the next room and makes it visible.

There are TONS of wikis of how to generate rooms/dungeons that even show the code in C# OR show the steps to generate those dungeons/rooms. Its good learning experience :].