🎉 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!

Building a level editor

Started by
1 comment, last by Bully 24 years, 5 months ago
I was wondering how do people go about writing level editors with their graphic engines. I''m not asking about any particular engine, but just the broad idea. And how does the engine read the files which are saved with the level editor. Are there any tutorials dedicated to the subject. Or would someone be able to start me on my way? THanks -David
" The fastest code is the code you don't call "
Advertisement
Well, lessee now! The first thing you need to do is decide the format for each tile, how much information needs to be held there and the data sizes required for that information. Try to think of everything that your tile will need to be checked for cos it can be awkward adding things in later.

The next major considoration is the map size. Is it going to be a constant size, or are your maps gonna change size from level to level. If it is latter, then your going to have to be able to identify the size in your map somewher so your game knows how big it is. I would suggest setting up a header in your map file detailing the size of the map, location/name of the grafix it will need, perhaps the names of the adjoing maps (if you can go off the sides onto other maps), then your map data. Oh.. a version number in your header is always a good idea because you will invariably make ammendments to the map editor along the way, and incorrect file sizes can crash the thing badly.

As for the format for saving and loading files, well thats very much up to you. There is no reason why the map cant just be a text file, using fscanf() and fprintf() to save and load your map data, at least that way its easy enough to load the file up in notepad to make sure it is saving what you think it should be. Of course this makes the map files huge, but once you have got it working you can change the load/save routines to binary format.


Hope that helps..



--== Rapier ==--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Save the whales, feed the hungry, free the mallocs!
--== Rapier ==--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Save the whales, feed the hungry, free the mallocs!
Rapier hit the nail on the head, i feel. Just one more thing. I sketched out a byte scheme detailing my Tile object so that i could save and load them faster. Find a way to represent all the attributes of your tiles in bytes, then in the header file, specify the length in bytes of each tile. That way, when you are done with the header, you can read in 3 bytes or whatever and make a map tile out of that.

Whatever method you choose to represent the tiles, just make sure that that is in the header too, so you can make changes to the structure with as little changing of your map loading code as possible.

This topic is closed to new replies.

Advertisement