I'm trying to have a top-down 2D map load in chunks, sort of similar to Minecraft. I want to always have the chunk the player is in loaded, along with all eight adjacent chunks. So, once it's determined that a player is inside (or above, rather) a given chunk, I want to have that chunk check each of the eight surrounding spaces for chunks and instantiate them where there are none.
Or in other words, if the player is anywhere in the chunk centered at (0,0) in world space, I want to check for chunks at (-1,1), (0,1), (1,1), (-1,0), (1,0), (-1,-1), (0,-1), & (1,-1), so I can then add any that are not present.
I'm coding in C#. I would think it would be simple to check presence with regard to location, and it probably is, but to my embarrassment, I can't seem to think of or find out how.
Alternatively, if there's a simpler or more efficient method for dealing with flat chunks like this, please let me know.
↧