So, I'm trying to build a 2d multiplayer bobmerman game. Right now I have whole map as 2d integer array. I'm thinking if I should change it to tilemap. In the future, I will want to be able to generate map from code, so keep that in mind.
Is it worth changing array to tilemap? What are the pros and cons of it? My server side is responsible for all the actions (movement, collision, placement), is it possible to connect with tilemap?
-
2\$\begingroup\$ We generally don't answer questions "which solution should I use, A or B?" because once you've identified two candidate solutions, the best way to find out which one works for your needs is to try it. That will give you far more reliable information about what works for your particular needs than the opinions of Internet strangers who don't know your project at all. Have you run into any difficulty with your current solution that you're unsure how to resolve? Or is anything blocking you from trying & testing the alternative, that we can help you overcome? \$\endgroup\$– DMGregory ♦May 3, 2019 at 12:07
-
\$\begingroup\$ I see. Thanks for the answer, I will try to test everything and see what works best for me. Currently I got some issues, but I don't think they're big enough to write about them here \$\endgroup\$– EivysesMay 4, 2019 at 13:05
1 Answer
A "tile map" is generally just a term for an array of some form where the elements in the array represent tiles, so generally speaking what you're presenting here is a choice between nomenclature more than anything else. It's like the difference between:
Array2D<int> map;
and
struct TileMap {
Array2D<int> tiles;
};
TileMap map;
That said, encapsulating the underlying array in a more-specific type also lets you build some more advanced features (such as having separate, sparse arrays for item placements for example).
You can of course also change int
to Tile
to store more information per cell of the map.
Whether or not you need to make these changes or should make these changes is up to you: if what you have now works for you, it's probably fine. If it doesn't work for you, you should make the changes that lead you to solve whatever specific issues you have.