Advertisement Jump to content
Sign in to follow this  

Level File Format Question

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

Hello everyone, I have decided after creating my first two games with DirectX I am ready to take on a serious project and create my first side scroller. With this in mind I am trying to gather some information/opinions from the pro's out there. I have a question that is probably basic for you guys, but I can't seem to find the answer anywhere. I am stumped as to how to store the levels for my game. I want to make them separate files as they should be but I'm not sure what the best file format or way to do this is. I remember a long time ago reading the source for a simple vb game that just read a txt file and had the level designed using different characters to represent different things and it looped through and created a specific tiles, character, enemy, etc for each letter character in the txt file. Now I know this would work, but I think there has to be a better way that would allow for more detailed level design. Any help would be awesome. [Edited by - jrmiller84 on September 10, 2005 9:22:04 AM]

Share this post

Link to post
Share on other sites
You might want to search for articals related to Quake3 BSP loading. I know there are some decent ones out there that talk about the format of level file. Sorry I do not have a link handy but it should be a quick google search.

To give you a littel more detail on how one might design a level file format you might want to start by getting chunks of info from your file. Also note that it is a very good idea to create two versions of a level/save load format. One that is text format that a human can scan though and make sure things are done correctly and one that is binary so I can be loaded quickly.


struct LevelHeader
//Header details
int version;
char levelName[256];

//The header will hold counts of each chunk type and an offset into the file
int numLevelShapes;
int offestLevelShapes;

int numMonsters;
int offsetMonsters;


So lets say you you want to load the chunk data for all the monsters in your level.

struct MonsterData
int type;
int hp;
Vec3 position;

First you always read in the header which is located into the begining of the file. The LevelHeader struct will now be filled with data. You would seek the to the memory location in the file to the offsetMonsters which is where the first check of monster data begins. You then loop though numMonsters reading in a chunk of file data into MonsterData. To the same thing for your LevelShapes and so on.

I don't want to say this IS the way to do it but I think it will give you a good idea of how to design your file format. It is important that you have something you are happy with and fits your needs best. Best of luck!

Share this post

Link to post
Share on other sites
Yeah I knew there would have to be some way of determining many of the main aspects of the level, like poly count, level size, textures, etc, but I wasnt sure the best way of doing it. I havent worked with reading binary file formats yet so I suppose it's a good time to get started. Although I suppose it doesn't necessarily have to be in binary as long as it's formatted in an organized way. I found a good article on BSP files at This should help me quite a bit. I didnt realize that the Quake BSP files were such a good starting point for map design. Thanks!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!