Sign in to follow this  
Lance Mazon

Best Method For IsoMetric Multi-Level Map Storage

Recommended Posts

Up until now, I've been using a simple flat text file that just defined the x/y coordinates of the first tile, and then mapped every character to a tile. This worked well for getting the basic engine up and running, but now I'm to the point where the Isometric engine is running fine, and I need to start making a world generator and adding features. Clearly, it's time to add in real map data storage. The method should be pretty quick, and I'll want to be able to divide up the map into chunks and save and load chunks fairly quickly. Any recommendations on a format/method of doing this? Thanks in advance...


Share this post

Link to post
Share on other sites
I would make up each tile as a model with a specific name (supposing you're using 3D tiles), place them in Blender, replicating them by ALT+D, then export to collada.

If this is too complicated, here's a method I've used in the past with moderate success.
I used a spreadsheet which would export in CSV.
Each spreadsheet cell would contain one or more of the following codes[list]
[*]nswe: an exit is present going north-south-west-east
[*]o: origin of layer. Different floors were assembled by matching origin position. Origin had position (0,0)
[*]other stuff you're likely not interested
[*]in your case, you might add a tag such as TILE:NUMBER to select model. Or maybe TILE:IMAGERESOURCE.
This proven quite fast for defining layouts. As 3D information is not readily available, matching positions between different floors [size=2]("I want this room to be on top of... this other room below")[/size] proven more involved than predicted. I then switched to the blender+collada oriented method and I'm now very happy with it. Edited by Krohm

Share this post

Link to post
Share on other sites
I should be a little more specific. Currently my "world" is stored internally as a Dictionary<Vector, Tile>. The vector class is, as you may have gathered, a simple vector with x, y, z values. The Tile class holds data related to a specific title, as well as a Sprite class. I'm thinking the best bet is to divide the map into chunks, and serialize the resulting chunk class, dictionary and all. Comments?

Share this post

Link to post
Share on other sites
I ended up just writing a file for a 10 (layer) isometric world that was 1000x1000 the filesize would get huge... mostly all of those tiles were blank.
So I ended up having my base tile and any layers of tiles above it would be part of a vector(data vector) (increasing with the Z axis) I could just check at draw time.

I ended up doing something like this as output binary to a file:

(int) FileVersion
(int) Checksum - The checksum is the total of the tilenumber for each given tile used to check data integrity.
(int) Number of tile records - I only store tiles that actually have data on them (On the base 0 level)

(for each base tile)
(int) X
(int) Y
(int) Tile - Add to checksum
(int) Number of Additional Levels on this tile
----(If > 0 parse each addtional level)
[indent=1](int) X[/indent]
[indent=1](int) Y[/indent]
[indent=1](int) Tile - Add to checksum[/indent]

(As always I am sure there are way better ways of doing this)

Share this post

Link to post
Share on other sites
[quote name='Lance42' timestamp='1347559543' post='4979794']
Ah... If I serialize the dictionary, that will do for now, but ultimately I shouldn't be serializing the sprite as well, which I will be at first. Silly. =D

What I was trying to say was just store the pertinant data to save and load and ignore everything else =)
(Which is exactly what you just said)

Dictionaries are neat I need to use them more often.
I think as a hold over from C++ I tend to store all of my stuff in vectors of a given class and refernce everything by a number.
Something like:
int TileReference = y + (MapWidth * x) ;
Then you could have s single 1d vector with all of your map tiles (as part of a class) in it making it really easy to export / import data.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this