Level Editor Help (SDL)

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
xx6heartless6xx
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 80
Joined: Wed Feb 02, 2011 9:42 pm

Level Editor Help (SDL)

Post by xx6heartless6xx »

I learned how to make a level editor from lazyfoo by reading off numbers from a map file and then applying the desired tiles. I am in the process of making a level editor for my game but I dont know how to have it work with my game. I have my level editor and game application in separate programs and separate files.

After I save a level from my level it saves my map file in the level editor folders and I need to manually transfer it to my game application folders each time I make a change to the level. Is there any easier way where I do not need to manually transfer the map file to my game application folder after I change it?

I thought of merging them into one program and then having an option to run the level editor or game but that seems like too much of a hassle. I would rather have two separate programs. Need help, thanks.
User avatar
bnpph
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 75
Joined: Thu Mar 10, 2011 12:30 pm

Re: Level Editor Help (SDL)

Post by bnpph »

3 options:
1. hardcode the directory the correct directory into your game.
2. make a config file that contains the correct directory and load it when your level editor starts. This is probably the best option.
3. use a "save-as" dialog box.
User avatar
Milch
Chaos Rift Junior
Chaos Rift Junior
Posts: 241
Joined: Sat Jul 11, 2009 5:55 am
Programming Language of Choice: C++
Location: Austria, Vienna

Re: Level Editor Help (SDL)

Post by Milch »

You could simply give the program arguments when you start it:
e.g 'game.exe -L[PathToLevel]'
The game would then check it and automatically load the level.
Follow me on twitter!
User avatar
xx6heartless6xx
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 80
Joined: Wed Feb 02, 2011 9:42 pm

Re: Level Editor Help (SDL)

Post by xx6heartless6xx »

Thanks, I think I'll tell the level editor to access the map file in the game application folder. When I load files, I usually have them all in the same folder so I would just need to do a simple command to load the map file like this:

Code: Select all

std::ifstream map( "Tile.map" );
How can I load a file when the file is located outside of the same folder as the game folder? Can I just put ifstream map( "C:\Tile.map")?
User avatar
BugInTheSYS
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 88
Joined: Mon Feb 07, 2011 4:16 pm
Current Project: Vintage Roads
Favorite Gaming Platforms: PC
Programming Language of Choice: C++, Delphi
Location: Pinneberg, Germany
Contact:

Re: Level Editor Help (SDL)

Post by BugInTheSYS »

"C:\Tile.map" will give you an error. Since \ indicates a character constant such as \n or \t, you would have to use \\ if you mean the "real backslash".
And you can provide absolute paths (as in "c:\\blah.txt") or relative paths ("blah.txt") with the slight difference that the relative path will be understood as appended to the path of the directory your executable is located in.
Someday, everything will go to /dev/null. - Bug's prophecy 13:37
Aleios
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 78
Joined: Mon Feb 21, 2011 2:55 am
Current Project: Aleios Engine
Favorite Gaming Platforms: PC, Dreamcast
Programming Language of Choice: C++
Location: Melbourne, Australia

Re: Level Editor Help (SDL)

Post by Aleios »

Or you could use the good old forward slash / instead of using C:\\blah.txt you would simply do C:/blah.txt

And i would be saving the file either next to the executable for the game, or in a sub directory of the executable's location.
What you need to do is save the file and either do a manual copy, or use one of the options provided by bnpph.
Image
Post Reply