Some advice on SFML map editor?

I've been working on a space shooter in SFML, I've been making good progress but there's been a problem that I've been sidestepping for a while. I'm not just making levels randomly spawn enemies. Levels are also to contain tiles, i.e metal tiles grouped together here and there. I also need to have some control over where some enemies are. I've looked at some pre-made map editors but they also have one or more of the following problems.

1.) No way to know how to load saved files (undocumented file format)
2.) The map editor flat out sucks(Unstable, several bugs)
3.) Doesn't fit my needs and a.) Can't be edited b.) Code is way too horrible to work with (All in main.cpp for one of them!)

I have some idea of how I'll approach this however I want to see if I can get some advice before I start.

I don't have a good answer for this. I've never found a free 2D map editor I was happy with. I've always written my own.

If you find a good one, I'd be interested in hearing about it.
Disch:
I don't have a good answer for this. I've never found a free 2D map editor I was happy with. I've always written my own.

If you find a good one, I'd be interested in hearing about it.


Funny story I've seen you on SFML forums. I was stating why I can't use a pre-made map editor sorry bad communication. I'm asking for advice on writing one, which I'd actually really like to hear from you on this. I already have an idea, but I don't know if there are some notable things you learnt from experience perhaps?
Have you looked at Tiled http://www.mapeditor.org/ I think its pretty decent and there are several map loaders for its tmx files like http://trederia.blogspot.com/2013/05/tiled-map-loader-for-sfml.html
Well, I actually was planning to make something like a tile map-editor, and have it thought out. I haven't started on the project, but maybe you could do it for me. (And making it publicly open as well as open source could help other people in need, just as you are now).

Note: Everything here should be modified to fit your needs.

First, you will have to think of the types of entities you will have:
- Static entities (solid objects that don't move)
- Dynamic entities (solid objects that move)
- Background entities for both static and dynamic (non-solid entities that move/don't move)

Secondly, write a simple editor in SFML that lets you click on a tile that will change it's color, or something simple along those lines. Eventually, make it so you can click and place entities of any time, along with linking them to an image file (make it relative to a location so it works on any computer with the files).

Saving the file could be simple, treat it as an image where each pixel has a bunch of data. The pixel size would be the smallest tile (this could be optimized). Go across the map and in order save all the data about each tile, and at the beginning have a number that represents the size of the map (so your code knows where to place each tile).

Then, write a library with functions that loads your map and has a class for interacting with the dynamic entities (both physical and background). This would just have to have basic things like change animation, move, and any other basic things. Then, have this library be able to dynamically create and destroy entities, for run-time modifications of the map like spawning monsters/spaceships/whatever, or being able to build stuff and/or destroy stuff.

Last, if you want to make this code usable for anyone, include a second library that requires the first library (or just include this in the first if you want it to be dependent on SFML). This library would handle the actual rendering of the map, whereas the other library would just handle the data and calculations part of it.

This, would be an amazing 2D map editor, especially if it's free for public use, and made to generalize to all sorts of 2D games (and maybe even 3D, who knows?).
That would be nice, but it would also be a lot of work and with my level of experience would likely have many problems ;). I am surprised though that there isn't some popular open source project for something of the sort.
Well, that is probably going to be my next project. Whether I'm going to make it opensource or not, I'm not sure yet. If I do make it, I'll be sure to let you know how you can get a copy.
KISS. Level editors need not be an "all in one" game editor. Animations and other object attributes can be edited in some other editor... or not at all (if you store them as plain text... any text editor will do)

For editors I almost always use a widgetry lib. If for nothing else than for menus, dialogs/forms, and other common controls. I'm a fan of wxWidgets.... and there's a wxSFMLCanvas addon which will allow you to use wx for the widgetry stuff, while doing your actual drawing with SFML.
closed account (3qX21hU5)
I would just like to add that unless you are planning to have the map editor run inside of your game you don't need to use the same library or even language as your game.

I used C# when making my map editor for my SFML game. The only job of the map editor really needs to do (In its most basic form) is output a file that holds the maps information (Like tile information which could be what image to use from you tileset or if it is solid and stuff like that) in it. That file could be just a plain text file or a XML or whatever you want it is up to you. Once you get that down you can get to more advance stuff like adding layers to the map editor, and other fun stuff.

I just made a WPF application with a section on the right that had a grid like structure that I could setup, a section that displays my tilesets and a properties box for each tile of the map.

I can send you the code (Though it will require C# and WPF knowledge) or the application if you want to try it out. The map format it outputs in is a subset of XML and is quite easy to parse the information from.
Last edited on
Zereo:
I used C# when making my map editor for my SFML game.


I'm glad to know I wasn't thinking crazy then, because I can't lie C# is "enchanting" when it comes to GUI's, especially WPF. Qt is great too but honestly I have the worst luck with Qt. (There's always something that goes wrong that's typically a rare bug, I can never seem to win. Whether it be setting up the compiler, GUI freezes etc.)

I would definitely be interested in seeing the code Zereo, if you're sure you're ok with it. If I really need access to SFML I'll just use the C# binding, but I can imagine it wouldn't be necessary. I'm not too familiar with WPF is only problem. I know C#, but I might have to reference a bit since it's WPF also. (Unfortunately I've only learnt so much of it.)

I've been leaning more towards a binary file system. Some people really dislike doing that, but binary has it's pros as well.
closed account (3qX21hU5)
Sure no problem I will send it to you either sometime tomorrow or the day after (At the casino for the weekend and not sure how long we are going to stay).
You're in so much luck.

I developed a file format 7 months ago for my RPG Engine. It's in SDL, if you don't mind. No documentation, just code & an executable.

(Actually I just dump info into a file and read it :P)...

If you're interested, just tell me.

I really never added mob support to the map because I really didn't need to, it shouldn't be that hard.
Topic archived. No new replies allowed.