Okay, that subject was pretty random but it kinda describes what I’m looking for…
Anyways. I am trying to make a game world system that is structured in an array.
(these are arrays but I present them this way for ease of visualization):
I00I01I02I03I04I05I
I10I11I12I13I14I15I
I20I21I22I23I24I25I
I30I31I32I33I34I35I
I40I41I42I43I44I45I
I50I51I52I53I54I55I
Every cell in this array presents one screen in the game world. You could think of them as rooms. Each of them then contains their own arrays to present the tilemaps in these rooms.
But here is where the problem comes in. Of course I cannot render all those screen at the same time, that would be just overkill. So my solution is to only load the screens around myself (my current screen is the green one, the adjacent ones that will be loaded are the red ones):
I00I01I02I03I04I05I
I10I11I12I13I14I15I
I20I21I22I23I24I25I
I30I31I32I33I34I35I
I40I41I42I43I44I45I
I50I51I52I53I54I55I
Now the problem is: How do I load and unload the screens around me dynamically? I can’t think of any mechanics related to loading this stuff, and even more problems are caused by the fact that I should dynamically unload and load them as I move. of course it would be good if the new edges would load in the background. The new maps also have to be offset around my current map…
If anyone can help, I’d appreciate it. It might help to know that the “room” size is always the same.
Thanks in advance!