🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

SDL / MFC level editor?

Started by
6 comments, last by dragonbide 19 years, 11 months ago
Hey. I made a relatively simple SDL snake game. It loads level information (background pic, obsticle pic, snake length, music, etc) from text files in the program's main directory. I'm trying to figure out the best way to make a graphical level editor... it would have possibly a graphic editor for the obsticle sprites (50x50), and an image loading / cropping method for the background pics, and some sort of input dialog for all the other parameters. What would you sudgest? One idea I had was to try and implement an SDL window inside an MFC dialog, though I havn't attempted this and I realize it would probably be a bear to get up and running. In the end all it would have to do is output the numbers / filenames to the text files, and the game would work with them automatically.
-------------------------------Visit my game site!
Advertisement
Hey Dragon,

I'm actually in the exact same position as you, but maybe a few days ahead. I had a base game engine done using SDL and OpenGL. To make the level editor, I simply created a new project that was MFC compatible (it's an option when u create in VS/.Net). Then I just added all the files from the original project (the base game engine), and compiled. Doing that you should now have the same game engine but it's MFC compatible. The next thing I did was create a dialog box with all my editable data for the level. Now add a line of code to your gameInitialize function that says to create and show the dialog box. I can now change anything about a level with this dialog box, and have it show up in the SDL window immediatly and looking exactly as it would in game! Woot!

I actually have a small picture of what it looks like at my website here: http://www.matthughson.com/assets/misc/leveleditor_04_08_03.jpg

This is a LOT easier than trying to render an SDL surface to a dialog box, but maybe not as nice looking. However, its really easy to set-up and program. Let me know if you have any troubles!

Matt Hughson
__________________________________[ Website ] [ Résumé ] [ [email=contact[at]matthughson[dot]com]Contact[/email] ][ Have I been Helpful? Hook me up! ]
Sweet, I'll try that out (I'm usin VS.net 2003). Do you know of any sites with tutorials / examples on the subject?
-------------------------------Visit my game site!
Nah sorry, don't know of any tutorials. But assuming you're comfortable with MFC you should be good.

I'll keep an eye here incase you run into any problems.

Matt Hughson
__________________________________[ Website ] [ Résumé ] [ [email=contact[at]matthughson[dot]com]Contact[/email] ][ Have I been Helpful? Hook me up! ]
Hey, how did you start your project? Still just an empty win32 project (without console)? The only way it'll let me include MFC in the project settings is if I make it as a console project, then I get compilation errors when adding in SDL. Should I make a console project with MFC, then delete the main function it automatically inserts and use "int main(int argc, char **argv)" instead?

*edit* I was able to create an mfc dialog project and include the sdl libraries and initialize a window with the dialog... it seems that including the SDLmain library messes something up, but it works fine without it.

[Edited by - dragonbide on August 10, 2004 7:37:00 PM]
-------------------------------Visit my game site!
Ok, so what I did was create a console app with MFC compatability (as you suspected). This probably isn't the only way, nor the best, but for a level editor it works fine. You will need to replace the main function it creates with with the SDL main function:

int main(int argc, char *argv[])

...also as you suspected =) You shouldn't get any errors. If you still get errors, copy and paste them onto here, and maybe it will jar some memory of me going through a similar problem.

Rock On!
Matt Hughson
__________________________________[ Website ] [ Résumé ] [ [email=contact[at]matthughson[dot]com]Contact[/email] ][ Have I been Helpful? Hook me up! ]
I know this may seem slightly off-topic since it is not SDL... but... It is fairly easy to implement the Allegro library with MFC. I believe that there are tutorials on how to do this on the Pixelate site (google for it).

It basically consists of drawing everything to an Allegro memory bitmap and then using blit_to_hdc() (I believe that's what it's called). Then again, if you don't already know Allegro that may be one more thing to learn.

Not to diss SDL though--I'm actually using it on my current game.

Peace out and good luck.
-Greg
Cool, I'll try making that console project as soon as I get off work. I should be able to figure it out from there.
-------------------------------Visit my game site!

This topic is closed to new replies.

Advertisement