Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


2D Map Storage

This topic is 5616 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

Okay I am working on an rts/rpg/sim hybrid that uses a 2D world map based on tiles. Now I am using Direct3D to do this in and I have run into two questions. Firstly what is a good way to store map data? I mean lets say I have this vast town with moving characters and lots of various tiles etc etc. How do I store this town while the player is not there? Should it be in a text data file which gives the tile name, any functions it runs when its used etc or is there some other better way to do it? Secondly whats the best way to do colision detection? From what I understand most 2D games have a secondary layer of images. That layer would just be two colors like black and pink. Pink would be areas you cant walk on and black would be those you could. The user wouldnt see these areas but they would be checked when the character is moving around. Is this the best way or are there other better ways?

Share this post

Link to post
Share on other sites
When I did a tile based game (it didn''t get far, but the mapping was done) I made a class. eg
 class CTile
// etc

In here I kept the tile type, image, what''s on it etc
Then I made an array of these and then just dumped the whole lot in a file. But knowing little of what your game is about, it is hard to say how to store the information you need. As we don''t know what information you need.

I don''t have a signature, sorry.

Share this post

Link to post
Share on other sites
Things which should go in a map file for a 2D tile map (IMO):
* General map info (name, size, etc.)
* Tile info. Most games are using multiple layers of visible maps, which are drawn on top of each other, so you''d better store all the layers here.
* Collision info. Where you can walk and where you can''t.
* Scripts attached to certain tiles, or the entire map
* Start location of NPCs
* Scripts attached to NPCs
* Items (could be included in #2)

There can be more (or less) depending on what kind of game you are making, and perhaps I forgot something here. Note that the script info shouldn''t include the scripts themselves, only references to them (for example, "duckgotkilled.script"), to make it easier to fix bugs, update functionality, reduce map file size, etc.

For crying out loud, she has fishes coming out of her head on either side. How can you find this hot?!

Share this post

Link to post
Share on other sites
Well, I would think you could store the map serially, and then read it to an array/matrix format where corresponding numbers like 0,1,2... could represent something. A key symbol in there could define certain items and such.

example: 6x9 tile map

0 == space
1 == wall
2 == special thing
8 == start
9 == end

Something like that.

Share this post

Link to post
Share on other sites

  • 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!