1
\$\begingroup\$

Say i have 10 towns in my world map. the world map right now is just a very large Tilemap. I'm curious as to what the standard is. I think it would be much more efficent to have a Tilemap for each town. If i want to walk from one town to another in the large tilemap I dont have an issue, but how can i do this if i had a Tilemap for each town? when is it best to load the upcoming Towns Tilemap?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Having one large tilemap is certainly the simplest way to go, but as you stated, it would be more efficient to have one for each zone and have the entire map cut down to a couples of square regions. It would allow you to free resources when a region is leaving the screen and reduce the range of the loops needed to draw all the tiles (though this can be easily implemented on a single Tilemap to draw only a portion of it).

To implement multiple Tilemap, you would probably need to save the x, y, width and height of each Tilemap relative to the original big Tilemap. This way, you can do rectangle collision to check if you need to load a given region and with the x and y coordinates, you can draw the tiles to the right cells, even when drawing multiple tilemaps.

Summary: It would be more efficient, but you would have to add systems to detect whether or not a givent TileMap needs to be loaded and drawn. The simplest solution would be to stick with the large Tilemap. And always remember this programming quote: "If it's not broken, don't bother fixing it". As long as the large Tilemap works and don't reduce the performances significantly, don't change it.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ This is exactly what i was looking for a little more insight. thank you. \$\endgroup\$
    – jcjunction
    Jul 9, 2014 at 16:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .