0

I'm making a tile-based adventure game in SpriteKit and I'm trying to figure out a good way to store my maps. A typical map might have 100x100 tile dimensions. Currently I have a very small 8x16 map which I'm storing in a 2x2 Swift array. However, making maps in arrays seems like bad practice as the map size increases. What would be the best way to store this map data?

A Tyshka
  • 3,830
  • 7
  • 24
  • 46
  • I would recommend changing how your question is worded, "Best way" leaves things up for debate. Just ask for a way to solve the problem, and let the community decide the best way by upvoting answers. – Knight0fDragon Mar 23 '16 at 19:22

2 Answers2

2

There is nothing wrong with using 2 dimensional arrays, in fact, if you use arrays, then you can save them into plists to make things easier for you.

I would personally write my own class that wraps around the 2D array so that it suits my needs (E.G. if I am adding a column, it will add the column to every row)

Knight0fDragon
  • 16,609
  • 2
  • 23
  • 44
0

I don't know if this suits your need but you could use the editor Tiled which offers you a visual way to create your maps.

Maps are saved as .tmx file (basically an XML file). Then you can import them in your game using one of the listed solutions. You can event create your own solution pretty easily (second answer in the given link)

This solution makes creating/modifying maps easier, but you have to use an external software.

Community
  • 1
  • 1
Heyfara
  • 511
  • 3
  • 21
  • I have looked into Tiled. I'm reluctant to use it because, as you stated, it requires external software. Also, I'm planning on eventually creating random maps in code so the game doesn't get boring. I believe Tiled only supports manually made maps. – A Tyshka Mar 24 '16 at 16:07