Sign in to follow this  

Map Editor with SDL

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

im trying to make a map editor with SDL and i seem to be stuck at square 1, I cant figure out how to get a file path for an image passed into my program so i can load it and use it for my map, any help in this area would be much appreciated thx [smile]

Share this post


Link to post
Share on other sites
Just curious, but why SDL? I don't think SDL is a very good app suited for creating something like a map editor. After all, there's no GUI environment avaialble (although I'm sure there's a library here or there) and it just...doesn't seem like a good idea to me. Although I could definitely be wrong, and I'm sure its possible to make a map editor with SDL.


FYI: The game I'm working on uses SDL but our map editor is created with QT. Maps are saved/loaded from both the map editor and the game via Lua scripts. Its working out great so far. [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by raptorstrike
im trying to make a map editor with SDL and i seem to be stuck at square 1, I cant figure out how to get a file path for an image passed into my program so i can load it and use it for my map, any help in this area would be much appreciated


If you are using command line, then your main function should look something like this:
int main( int argc, char* argv[] )
argc is the number of arguments passed into your program. To process the arguments, you can access argv[index]. So for example:
int main( int argc, char* argv[] )
{
for( int x = 0; x < argc, x++ )
{
char* argument = argv[x+1];
}
return 0;
}

argv[0] will always contain the path of the executable, so you must start at index 1, then loop to argc. If you pass no arguments into your program, argc is 0 and argv[0] still contains the path to the executable.

If this is not what you want, please explain some more. [wink]

Share this post


Link to post
Share on other sites
yeah ive decided SDL is not a good choice, actually using Lua scripting was what i had in mind for saving/loading my maps as well. Anyway thx for the help and i think im going to look at some other library with GUI

Share this post


Link to post
Share on other sites
I've run into the same problem with you and came up with this solution:
  • Serialize the map class so that you can save and load the binary data straight to and from a file.
  • Make a whole new project that uses the same library that the original map class is in and load the binary data from the file.
  • Now you can use this new map editor project as an interface to make maps.
  • You could even export and import them from Excel charts or any other file format if you have the right libraries.
If you find out how to serialize the data, then you'll be able to make it work with any other project you make. Good luck!

Another solution would be to use the Mappy file format, which pretty much puts all bitmaps and tile map information into one file and has several functions to help you load the information. You use it with the common Mappy map editor.

Thanks to EDI and Washu for their help with getting my map class serialized.

Share this post


Link to post
Share on other sites

This topic is 4544 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this