Archived

This topic is now archived and is closed to further replies.

arwez

Map file format HELP!

Recommended Posts

how do I make a separte map file and open it up and read it within the code? Like in Starcraft they use .scm as the map file, what is the best way to make one? I don''t want to have to make a simple text file with characters for the map. also do directx games like starcraft and jagged alliance 2 use the same structures/ methods of creating tile based games as what most of the gamedev articles talk about?

Share this post


Link to post
Share on other sites
There''s no trick to creating map files. You just open a file, write the data you need, close it, end of story. Your question is too general, really. Do you understand file I/O and want to know what a good format is, or do you not know how to use files? Nobody can tell you a good map format because every single game out there is going to have different information that needs to be stored in order to represent a map. It''s entirely up to you how you want to store it, but it should be as easy as creating some sort of header to tell you what kind of file it is, and what kind of information is in the file... then dumping the relevant variables, arrays, or structures into the file with fwrite().

-Ironblayde
 Aeon Software

Down with Tiberia!
"All your women are belong to me." - Nekrophidius

Share this post


Link to post
Share on other sites
Can you give me an example of a map format? Like where you put the map where you put the info for walkability etc. Then how do you read in that file and translate it to code?

Share this post


Link to post
Share on other sites
You may think to build a map file as follows:
1. Map Header (a field with special chars to verify that file really contains YOUR map (e.g.:''MAP FILE HERE'') that you''ll check every time you load the map, info about size of the map and number of layers, type of game mode you''re playing, if your game supports many game modes etc. You may want to reserve a few bytes (say 100) for future development of the map file format.

2. Layers independent from the actual game: terrain, trees & undestroyable buildings info.

3. Layers with the actual game info: units info, destroyable buildings info etc.

Hope this one helps,
A

Share this post


Link to post
Share on other sites
You want to know how to read a file and put the data in your game ok?

I have written a converter from *.ase -> *.myownfileformat
It reads the data from the ase, converts them, and saves them to a new file. Its a hack. But maybe it can help you understand.

Here is the link.

Another page to go is the gamedev i/o tut.

Edited by - Jonus on March 23, 2001 2:07:43 PM

Share this post


Link to post
Share on other sites
Wow... you should slow down a bit, Arwez. I don''t want to sound condescending, but you need to learn a little about datafile management before you can write a game that requires custom map formats.

Read up on binary file I/O, cin/cout objects, fread and related functions, fstream and related objects and commands.

Next you need to develop a good file format. I would recommend serial data access in a first major project. It isn''t pretty but it''s fairly simple to conceptualize. Create structures for your tiles, then read and write structures to and from your files.

Try making a small database program that lets you add name, age, and phone numbers to a list of items, and store these in a binary file. Then try reading from the file, and make it work. Once you understand the basics, then you can get fancy and write large database management code. (Games don''t sound like they need this, but it''s fundamental for any large or complicated application that requires stored, manageable, updateable, dynamic data, and game map files are no exception.)

You CAN learn how to copy code here, but it''s probably better that you learn how to answer your own questions, or how to design.

MatrixCubed
http://MatrixCubed.org

Share this post


Link to post
Share on other sites
I agree with MatrixCubed, our team has written a D3D Iso engine, but when it came to the storing,manipulating of the data from the characters,items,map we got stuck. Its a really important topic for every app.

Share this post


Link to post
Share on other sites
I already know the basics for file io. What I am trying to find out is a simple example of a file. What do you put on the file?
this is how I think a format should go, am I correct?:

islandmap.txt

MAPNAME: island
MAPSIZE: 50
MAPCHARS:

11111111111
1 1
1 1
11 1
11111111111


Is that the best way to do it?
How would you do the second layer?

Share this post


Link to post
Share on other sites