Coding a Map Editor

Started by
8 comments, last by DekuTree64 14 years, 11 months ago
I've been searching around on google and I can't seem to find any articles or anything on creating a map editor (preferably with C++). Does anyone have anything that could point me in the proper direction? EDIT: I should mention this is for a 2D project.
Advertisement
Well, the first step is going to be to figure out exactly what kind of features you need. What sort of map is it? Tile based? Isometric? Platformer? What objects do you need to place? Traps? Bonuses? Powerups? Candy/generic points objects? Enemies? Teleporters? Nuclear warheads? Flying pigs?

Once you've gathered as much information as you can about what the editor needs to do, we can move on to how to implement the various elements.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Well for the most part I know how the map will be structured. A layer based map with tiles and entities placed throughout each layer (I.E. The player, the npcs, hitboxes, a ladder..kind of like how the Source Engine handles entities). I have somewhat of an idea of what the form should look like, I'm just not sure where to start as far as coding goes.
I'd start with a simple renderer that draws the map structure, then add on things like tile editing and entity placement over time.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

So basically what you're saying is have a space on the form to render the map, and as I'm working on controls and such, add the capabilities to actually render the map in that space?
Quite the opposite actually, at least in my opinion.

Optimally, you want to be able to use the same map rendering code from your game as you use in the editor, to make sure that everything appears identically...and to ease the writing of the editor.

First, get the code to handle rendering of the maps. Then get that working inside of the form and build the controls around it.
What leads to the question: What was first? The Editor or The Game?
[size="2"]I like the Walrus best.
A portion of the game. Finishing the game before creating the tools is bad practice (designers can't work until your game is complete.) I'd say a good time to introduce tools would be when the code that relates to them has a fairly stable interface. Ie. When your base renderer is done, create a map editor.
You can have a look at my 2d level editor. It's in C# by it's close to C++.
- Iliak -
[ ArcEngine: An open source .Net gaming framework ]
[ Dungeon Eye: An open source remake of Eye of the Beholder II ]
I agree with TriggerB, get the game somewhat functional (maps rendering, player walking around, maybe some enemies), then make the map editor, and then finish the game code while you make levels. That's what I'm doing anyway. Currently near the end of the "make map editor" phase (using C++, with FLTK as my GUI library).

Map editors are pretty straightforward if you understand event-based programming. I started by defining the basic structures. A project has a list of maps, maps have some tilesets and a list of layers, layers have an array of tiles. Then make a window with scrollbars that displays the map. When you get a click event in that window, translate the mouse position to a tile coordinate in the map and plot the currently selected tile there. Make a window that displays the tileset, have click events in there set the currently selected tile, and voila, basic map editor.

There is a pretty big amount of work to be done, but none of it is particularly difficult. Probably the hardest part for me was setting up the GUI library :p
Post here if you get stuck on anything specific.

This topic is closed to new replies.

Advertisement