Thursday, May 24, 2007

Tiled Map Editor, Written In XNA

So I had been working on my game in XNA for a while when I decided that Tiled, a free open source Tiled Map Editor see: http://www.mapeditor.org/, that I had been using didn't support some of the features I wanted my Map Editor to have. This wasn't surprising since some of the features I wanted were somewhat Game Specific. Though I will tell you now that Tiled is an awesome Tiled Map Editor and by default it outputs saved files as XML. While I didn't copy any code from it when making my Map Editor I did take allot of ideas from the interface, tools, etc... and have to give the creator's allot of credit.

Tiled Map Editor Screen Shot:




The TileSet I am using in this screen shot is the same one that was used in the tutorial on XNA Resources, see: http://www.xnaresources.com/pages.asp?pageid=23. My TiledMap Engine was originally the one from that Tutorial. But I have made so many changes to it since that point that I would be surprised if anything is the same as that Tutorial anymore. I actually have several other tilesets I've built but this one is a nice one for testing since I haven't taken the time to really polish my other tilesets.

As you can see from the screen shot I have a decent interface setup with my pallet on the right side, Layers on the left side, Map right in the middle. Most of the important tools in the toolbar work, right now Lasso Select, Ellipse Select, Tile Picker, Cut/Copy/Paste, and undo/redo don't work yet. But I will start working on them later. Since I have the basic paint tools: Pencil, Eraser, Fill working and the basic selection tools: Magic Wand, and Rectangle Select working I decided to work on saving/loading. I am XML serializing the objects and so far I have quite a few of them capable of being saved.

Right now I am able to export/import TileSets, with the actual tileset texture image embedded in the file. I say embedded but really all I did was create an array of unsigned int's that represents the Texture and then use SetData to load them back into the texture.

My next problem with save/load is that the tiles in the maps are actually references of the tiles in the tilesets, so when I load a map I'll have to re reference all the objects, but when I XML serialize the maps I do know the ID of the tile, from which I can deduce the parent TileSet, so it shouldn't be a big deal.

After that I will need to finish my redesign of Zones and get it so those can save, along with all child maps, and then The World! or I should say my World object which contains a grid of Zones and other settings for the World. Once I can Save/Load, Export/Import all of the objects as a group or individually then I will start working on more features.

Truthfully I am getting tired of having to redo the same steps every time I debug... Click this menu, load that file, do this, do that... now I can finally test it, nope, didn't work, do it all again.

1 comment:

Anonymous said...

This is great info to know.