Jump to content
  • Advertisement
Sign in to follow this  
weegizzy

Storing 2D RPG map data

This topic is 4222 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am about to start creating a 2D tile-based RPG using C++ with OpneGL. One of the things I would like to do is create a map editor to create maps, and I was wondering if anyone could help on giving me some ideas of how to go about storing the map data in a file. The map file would have information on the graphic tiles, and also certain events or items which may be at certain locations on the map. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Perhaps you could store your map data as a 2D array of integers with each integer representing a different tile type. Perhaps each of these array elements could have properties that include not only the tile type, but the type and position of objects within the tile, etc. Just a thought.

Share this post


Link to post
Share on other sites
Well, you could go as simple as storing the tile data as a serie of ascii value's, limited by spaces and newlines, and add some keywords at the end to denote gameplay elements like triggers/items. I did this in a small ascii game prototype: Fryball prototype (source code). Explanation can be found here. ;)

The game I'm currently working on stores all this info in a single, binary file. First some header information, like the width, height, number of layers, and the starting indices of the various data blocks. Then comes a data block that refers to the used sprite images, then the tile layer data block (contains values that refer to these sprites), then a collision data block and at last the script block.

The advantages of a binary format are mostly file-size, and perhaps reading time, but that's probably pretty insignificant for small games. The advantage of a readable format, plain text, are that it's easy to modify a map when you don't have an editor available (yet).
I'm sure there's other reasons why you can choose a particular format and a particular data layout, but since you know what you want (hopefully ;)), I'll leave that up to you. :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!