Skip to main content
GameDev.net gamedev.net
🔒 Locked

what is a .map file format and how to use it in a tile game?

Started by graveyard filla May 15, 2004 at 8:45 PM 18 replies 8.8k views
Original Post
graveyard filla
graveyard filla
high, playing other peoples tile based games, i noticed that they store their map files in a .map file format. ive been using a regular txt file to store my data. i tried opening these files in VS.net and i get a file with a like a table of numbers which i dont understand. i searched google and the articles section of the site, but i cant find any help. could someone please explain to me what the point of a .map file format is? what it does? and most importantly, if you can explain how to use one with a tile based game that would be great. im setting up my map system in my tile based RPG now, and it would be great if this could give me an advantage in doing so. because so far its been a real pain trying to organize my maps/tiles. thanks a lot for any help!!! [edited by - graveyard filla on May 15, 2004 9:46:59 PM]
FTA, my 2D futuristic action MMORPG
bytecoder
bytecoder
.map is an extension, not a file format. Most people just name their map files with that extension because 1) it''s more explicit than .txt 2) it tells people it isn''t a text file. I could create a game that uses the extension .adfo2 for maps if I wanted to.
graveyard filla
graveyard filla
are you sure about that? because windows is telling me a .map file is a "Linker Address Map" . it even has its own icon and everything.
FTA, my 2D futuristic action MMORPG
nagromo
nagromo
Yes; that is the ''official'' use of .map; I could call my source code src.map and that doesn''t make it a linker map, though.
twix
twix
File extensions are completely unrelated to the actual format of the file, although of course nobody would give their data files a .exe extension or something strange like that. Make your own map format, it's fun.

[edited by - twix on May 15, 2004 11:34:28 PM]
Doc
Doc
Windows detects the type of file by the extension - it doesn''t care what is actually inside the file. If you renamed "foo.txt" to "foo.mpg" windows would suddenly think its a video, when you know that it isn''t.

".map" does sound too generic to be any specific file format, so it might just be whatever the developer decided to put in there.
graveyard filla
graveyard filla
ok well if thats true, how come when i rename the file to .txt, and open it in notepad, i get garbage? if i open it as a .map, VS.net opens it and i can read the letters/numbers , its like one big table of letters/numbers and what appears to be hex (i think) on a column along the side of the file... im trying to cut and paste it to show you guys but when i paste it i just get a small line of garbage... but heres what the first line looks like:

00000000 6A A1 59 A4 9B 01 01 01 01 01 01 01 01 01 01 01
.....10 // more number/letter thingies here
.....20
..up to ..90
.....a0
.....b0
.....c0
..up to f0
then to 100

this file is really big and the last row's hex? number in the file is 0000fdc0

so what is this? im thinking its some sort of special file dealy that will make making maps for tile games easier. ive seen this in a few diff games with tiles and i could probably use it. does anyone know whats the deal with them? its called a Link Address Map. thanks for any help


[edited by - graveyard filla on May 16, 2004 2:00:48 AM]
FTA, my 2D futuristic action MMORPG
smitty1276
smitty1276
You get garbage when you rename it .txt and open it in notepad, because it is NOT A TEXT FILE! That's what they have been trying to tell you. The file extension has nothing to do with what's in the file.

If you rename a file with .txt, it just makes Windows think that its a text file, and you can open it with notepad with a single click, but you will get garbage because it IS NOT A TEXT FILE.

When you open it it VS it probably just brings up hexadecimal representation of the binary data that is in the file. You could open any kind of file in a hex editor and probably see some readable information in it.

BTW, the "letter/number thingys" are hex... the first column is probably the offset or something.


[edited by - smitty1276 on May 16, 2004 2:01:47 AM]

[edited by - smitty1276 on May 16, 2004 2:02:58 AM]
graveyard filla
graveyard filla
the first person told me that it was just a txt file renamed to .map and the other person agreed with him... now your saying its not a txt file... the whole point is what the hell is a .map file then and how is it used in a tile based game?
FTA, my 2D futuristic action MMORPG
smitty1276
smitty1276
You don''t seem to be listening to any of us... the first person didn''t say that it was a text file, he said that someone might name it .map because that gives some better indication of what it does than .txt, .bin, .dat, or .anything_else.

Let me put it this way for you.

THERE IS NO SUCH THING AS A .MAP FILE. You can make up anything you want for it.

You apparantly have some software installed that uses .map as the extension for a "Linker Address Map". You apparantly also have a tile-based game that uses .map for something. This could be and most likely is a level map, but could also be a strange extension for a light map, a height map, or a data file for a creature called the "Mysterious Android Porpoise". The developer of the game can name any file anything he or she wants. It may be a text file, it may be and probably is a binary file. That binary file can have any data in it in any order the developer chooses.

There is no way, at all, to answer your question. You best bet is to use that hex editor in VS to pick thru the file yourself and figure out what''s in it.



Deusmaximus421
Deusmaximus421
ok dude, you have to listen to people and pay attention to what they say. Windows associates filetypes by extension only, not content. take a text file, a paper or something and rename it .mpg or .jpg windows will think it is a movie or picture respectively. A .map file is nothing special it is just what people like to call their level files. For instance an uncompiled quake bsp file has a .map extension but it is nothing whatsoever like the files you are intrested in (most likely). The reason you see garbage in notepad and hex in .net is most likely because these files are written in binary. You presumably write and read your files in ascii text. Most game data is stored in binary, it is MUCH MUCH faster to read and write. I suggest you google up how to deal with reading and writing files in binary, its very helpful then you can name it with whatever extension you want like ".iliketowritebinaryfiles" . Good luck with your game

Rob
Etnu
Etnu
Jesus H.

The file extension is completely and wholly irrelevant. The file extension is simply a quick way for windows to know what type of data is suppoed to be contained within the file. It doesn''t matter what''s actually in there, though; you can''t see that until you open it.

The reason you get "garbage" when you open notepad is because notepad is trying to display a binary file as an ASCII text file. That means it''s trying to read the file 1 byte at a time and displaying the characters it finds within.

Just ignore the file extensions. They''re completely and wholly arbitrary.

A .map file might be a million different things.

Oh, and any file you open up in VS with an unrecognized extension will display that way. It''s just a hex representation of the binary in the file.
---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.
graveyard filla
graveyard filla
ok guys, obviously theres a problem of miscommunication here.

i understand that windows lets you can rename any file to any extension and the little icon will change and stuff and it will most likely stop working the way its supposed to. it doesnt matter, you answered my question anyway. i didnt think it was just a regular map file written in binary (i always write in plain txt). when i opened it in VS it looked like a weird table of stuff which i didnt understand i was thinking that .map was some sort of format that had an advantage when making map files with a tile based game (ive seen this used in tile based games but i guess it could be used with anything)..... anyway... thanks for all your help even though you yelled at me...

[edited by - graveyard filla on May 16, 2004 2:25:32 AM]
FTA, my 2D futuristic action MMORPG
Zipster
Zipster
We''re not yelling... we''re talking loudly

Anyway, with VC, if it recognizes a special file format it will try to open it as such, otherwise it uses the default hexadecimal viewer (the table of stuff as you call it). For example, TXT is the usual extension used for plain text files, so that''s what VC assumes. If you were to give your file the ICO extension, VC would think it was an icon and try to parse it as such. It would probably result in an error
markr
markr
The game that you took the .map file from obviously has its own binary format for the file. This is probably not documented, nor obvious.

The makers of the game obviously had some reason for creating it this way, but we are not psychic, so unless they explained it, we don''t know what format it is or why they made it that way.

If you are working with smallish tilemaps, it is probably easier to use text files, at least to start with.

If you are creating bigger tilemaps, you could use a bitmap of some sort (8bit is popular for this purpose) and read its pixels as tiles.

Mark

RuneLancer
RuneLancer
VS has a hex editor built in.

File extensions are merely an extension to the name to give the system or the user an idea of what kind of data is contained in the file. It does not always indicate that a file contains the type of data the extension indicates. In fact, back on Win3.1 and DOS, files could only be 8 characters, a period, then 3 characters ("MYCATPIC.JPG"). It was common back then to use the extension when the name couldn''t fit ("LISTEDTA.BLE").

Now take a file, any file, and name it "(filename).TXT". Open it. Ooooh, notepad opens it! :D But wait, it''s probably incomprehensible junk. Ok, now rename it "(filename).MPG". Woah. Now your favorite media player opens it! But wait, it''s probably not going to work. Hrm. What gives? You just renamed it to .mpg, it''s SUPPOSED TO WORK!

You''re probably thinking, "Oh man, Rune, you''re a dumbass. ^^" and you''re right. If I were stupid enough to try to rename MyProject.cpp to MyProject.mpg and expect to see a movie of my game, I''d deserve to be shot. But here''s the thing: you''re expecting nearly the same thing out of that .map file. Like I said earlier, the extension may not always matter.

You''ve opened it with notepad. Random junk. Notepad expects text and displays text when it reads a file. If it happens on junk, it won''t care and still display it. You opened it with MSVC and got hex. Why not text? Because MSVC is supposed to switch to the hex display when it hits junk like this. So... what''s a .map file contain? Binary, obvious.

Now for the stuff you don''t know and that we do (mainly from experience; we can''t guess what the file you have on your PC is, although you seem to be expecting us to know inherantly how it works...) When you create a game, you USUALLY use binary files instead of text files because it uses less space in most situations ("255" is 3 characters but 1 byte...) and is more powerful than plain text. Most of the time, you''ll create your own formats because there isn''t an existing one that''ll fit your needs (which isn''t unusual for a game...)

Now here''s the answer to your post: these .map files are the above kind of files.
graveyard filla
graveyard filla
ok, its bothering me that you all think im an idiot. how was i suposed to know that VS opened up a unknown file as a hex editor? it was a simple mistake.. i looked at it and thought "oh shit... this .map must be some helper file for making tile based maps" (because ive seen a couple tile based games which did this).... i didnt realize they were just binary files and VS was acting as a hex editor...

the first person said
"Most people just name their map files with that extension because 1) it's more explicit than .txt 2) it tells people it isn't a text file"

this read to me as "most people just name their map with the exetension .map because 1) its more explicit then keeping it as a txt file (because its a text file) and 2) it tells people it isnt a REAL text file....(ie its just a file with a bunch of numbers in it)"

ok, im done explaining myself. thanks for all your help guys

[edited by - graveyard filla on May 16, 2004 4:33:03 PM]
\\

[edited by - graveyard filla on May 16, 2004 4:49:54 PM]
FTA, my 2D futuristic action MMORPG
leiavoia
leiavoia
well, that doesn''t mean that it COULDN''T be an ASCII file, it''s just that the programmer decided binary was better for that usage. If you saved a file as ASCII for YOUR map files, you could then hand-edit them which is somewhat usefull if you don''t have a dedicated map editor.
graveyard filla
graveyard filla
i actually save my maps as ASCII files, but the map data is half bit flags (ie hex numbers) so when i open it in notepad it looks like all garbage... guess i should look into binary file output... weird thing is that half the map data is a regular integer and the other half is bit flag(s), so i dont know why ALL of the text file is garbage....
FTA, my 2D futuristic action MMORPG
eFoDay
eFoDay
a .map file format is not a standard format.

it was probly created by the people that made the game. it could be a plain text or binary file.

rename it to .txt and try opening it in wordpad. if it looks all jumbled its probly binary.

they possibly built there own 2d map maker and saved data into a file and added the extension .map

if you could get the map editor and file format from them you could use it in your own game

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.