Which method to draw 2D map (for a game)

Hi there

Just a quick question. I am making good progress on my little space shooter test game and am now thinking about the next test, which would go more into the direction of my planned main project. For that test I want to draw a 2D map with rectangular tiles. I do have a fairly good idea of how to achieve this (with a few question marks here and there of course). However, after googling the subject it seems that there are two methods of doing it and I’m not quite sure which one would be better. So maybe someone here can answer that.

To draw the map, one could use one massive sprite and then overlay a grid onto it (which would be a second sprite of the same size) as well as smaller sprites to represent different things on the tiles (player, enemies, etc.). Managing coordinates should be pretty easy as each tile would occupy a certain number of pixels on the x and y axis, so anything within that range would be on that tile.

The alternative would be to use a tile system, where each tile is a separate sprite. The program then puts these together to form the entire map. Not quite sure how to manage coordinates on this one, but should not be witchcraft either.

Now I feel the first one would be easier to do and require less code (and research). In terms of memory, at the end of the day I feel it should be similar as more or less the same amount of pixels are loaded and drawn. The map will not be much larger than the screen resolution, so only loading what is on screen is not necessary performance wise.

What do you think?
Last edited on
I think if you have a static world, and it all fits in memory, the first method. This would be something like baldur's gate, where you have a short loading screen and then the area you play in is fixed and has distinct borders -- in BG, for example, walking to the edge of the map activates travel menu to another area, with the load screen and such.

If you have a design where instead of load screens, you scroll from one zone to the next (think diablo 3 maybe) then the second approach lets you drop off tiles on the opposite side of the map and add them as the player moves across the world you just constantly drop and add tiles to allow them to move through their universe.

Both approaches are still used a lot. With VR becoming a thing the second may overcome the first.

its not just about the code -- your game design matters!
Last edited on
Thanks! I indeed plan on having a static world. So in this case I will go with the first approach. Use a single big sprite for the map, a second one for the grid overlay and then handle individual tiles thorugh a separate, "invisible" layer.
Topic archived. No new replies allowed.