Custom file formats
Moderator: Coders of Rage
Custom file formats
Hi, i am trying to make my own file format for 2d maps, and i have googled it, but i can't seem to get any good information on how to create it... any help?
Personal Youtube: http://www.youtube.com/user/xXShadowAsasNXx
Prelimse Studios Youtube: http://www.youtube.com/user/PrelimseStudios
Prelimse Studios Website: http://www.prelimsestudios.com/
Prelimse Studios Youtube: http://www.youtube.com/user/PrelimseStudios
Prelimse Studios Website: http://www.prelimsestudios.com/
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: Custom file formats
Just name the file whatever you want.... You could make it "cow.moo", "chicken.fowl", ANYTHING.
hope I helped
hope I helped
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
- JaxDragon
- Chaos Rift Junior
- Posts: 395
- Joined: Mon Aug 04, 2008 2:03 pm
- Current Project: Kanoba Engine
- Favorite Gaming Platforms: PS3, PC
- Programming Language of Choice: C++
- Location: Northeast NC
Re: Custom file formats
I would recommend saving them all as one format(PNG for example). Once the tiles are saved as a PNG, just rename them to have any extension you want. Load them using the same way you would load a png, except your file name shouldnt end with png ^^
Re: Custom file formats
i think he is refering to making binar files, not noramal ones
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
Dad, "Yea well I have a fan belt in street fighting"
Re: Custom file formats
I'm talking about having a custom 2d MAP format that i can load into my game engine... not just renamed files.
Personal Youtube: http://www.youtube.com/user/xXShadowAsasNXx
Prelimse Studios Youtube: http://www.youtube.com/user/PrelimseStudios
Prelimse Studios Website: http://www.prelimsestudios.com/
Prelimse Studios Youtube: http://www.youtube.com/user/PrelimseStudios
Prelimse Studios Website: http://www.prelimsestudios.com/
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: Custom file formats
As in a file containing a list of all the tile types and stuff in a map/level? If so, just name the file whatever you want.
If you're talking about something similar to saving an image from raw data, I have no clue.
If you're talking about something similar to saving an image from raw data, I have no clue.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Re: Custom file formats
i dont mean a file as in "C:\Program Files" i mean a file format, as in map.<format here> that a game engine can load, it contains the tiles for the map as well as the positions and if it is collidable, as well as some other stuff
Personal Youtube: http://www.youtube.com/user/xXShadowAsasNXx
Prelimse Studios Youtube: http://www.youtube.com/user/PrelimseStudios
Prelimse Studios Website: http://www.prelimsestudios.com/
Prelimse Studios Youtube: http://www.youtube.com/user/PrelimseStudios
Prelimse Studios Website: http://www.prelimsestudios.com/
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: Custom file formats
That's what I meant the first time. The format doesn't matter really, so long as it is a text file (not necessarily .txt, just containing text data), unless, of course, there is already a registry entry for that file format, and that entry says that it's, say, an image file (so you wouldn't use .png, .jpg, etc.). Other than those small restrictions, you can make it whatever you want. like I said before, you could make it moose.cow if you wanted to!
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Re: Custom file formats
So would i use C++ filestream to read chunks of the file or something??? and would there be a way to encrypt the files so you could not read them in notepad or any other text editor?
Personal Youtube: http://www.youtube.com/user/xXShadowAsasNXx
Prelimse Studios Youtube: http://www.youtube.com/user/PrelimseStudios
Prelimse Studios Website: http://www.prelimsestudios.com/
Prelimse Studios Youtube: http://www.youtube.com/user/PrelimseStudios
Prelimse Studios Website: http://www.prelimsestudios.com/
Re: Custom file formats
well thechnically tou can use any extension you want, even .bmp .jpg .mp3 .wav
anyways. if you are just goint to have something like
or whatever, that you read each line parse it and rebuild the level each time its loaded that fine.
another ( better ) option it to do it with binary files.
you would have lets say a level class, with all you data variables inside.
and you would just write the class to a binary file, then read the bytes from the file and store it in a level class object again.
down side to this is that your file will be non human readable, so you will have to have an editor.
nice thing about this is that its alot faster, file size is significantly smaller. parsers are practically non exsistant. easy of use. and scalability is infinate.
(so its a far better option.)
anyways. if you are just goint to have something like
Code: Select all
map001
object 5
0,0,10,10,brick.jpg
10,0,10,10,brick.jpg
10,0,10,10,brick.jpg
20,0,10,10,brick.jpg
another ( better ) option it to do it with binary files.
you would have lets say a level class, with all you data variables inside.
and you would just write the class to a binary file, then read the bytes from the file and store it in a level class object again.
down side to this is that your file will be non human readable, so you will have to have an editor.
nice thing about this is that its alot faster, file size is significantly smaller. parsers are practically non exsistant. easy of use. and scalability is infinate.
(so its a far better option.)
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
Dad, "Yea well I have a fan belt in street fighting"
- Moosader
- Game Developer
- Posts: 1081
- Joined: Wed May 07, 2008 12:29 am
- Current Project: Find out at: http://www.youtube.com/coderrach
- Favorite Gaming Platforms: PC, NES, SNES, PS2, PS1, DS, PSP, X360, WII
- Programming Language of Choice: C++
- Location: Kansas City
- Contact:
Re: Custom file formats
Yeah, you can have it similar to 3D model files, listing each tile like ava said:
mapname
x, y, w, h, image
x, y, w, h, image
so it would load in the information for each tile during the load.
My maps are in a grid, with the number listed representing the x coordinate of the tile (divided by 32).
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
1 1 0 0 0 0 2 0
1 0 0 0 0 2 2 2
1 1 1 1 1 1 1 1
mapname
x, y, w, h, image
x, y, w, h, image
so it would load in the information for each tile during the load.
My maps are in a grid, with the number listed representing the x coordinate of the tile (divided by 32).
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
1 1 0 0 0 0 2 0
1 0 0 0 0 2 2 2
1 1 1 1 1 1 1 1
Re: Custom file formats
wht do so few people utilize binary files?
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
Dad, "Yea well I have a fan belt in street fighting"
Re: Custom file formats
Have a look at this.
You should get some ideas from it even though it's specifically for isometric maps. Also it's pretty old (1999) and even though it says it's C/C++, it's really only C.
You should get some ideas from it even though it's specifically for isometric maps. Also it's pretty old (1999) and even though it says it's C/C++, it's really only C.
- wtetzner
- Chaos Rift Regular
- Posts: 159
- Joined: Wed Feb 18, 2009 6:43 pm
- Current Project: waterbear, GBA game + editor
- Favorite Gaming Platforms: Game Boy Advance
- Programming Language of Choice: OCaml
- Location: TX
- Contact:
Re: Custom file formats
I've decided to go with SQLite as my level/resource file format. It's embeddable, extremely fast, and cross platform. Also, there are stand-alone applications you can use to query them, so you don't have to write your own editor before you can test your engine. And best of all, you can query it with SQL!
The novice realizes that the difference between code and data is trivial. The expert realizes that all code is data. And the true master realizes that all data is code.
Re: Custom file formats
as far as i know you still cant write entire objects to it... i may be wrong. but i think a self made binary file would still be beter in terms of that.wtetzner wrote:I've decided to go with SQLite as my level/resource file format. It's embeddable, extremely fast, and cross platform. Also, there are stand-alone applications you can use to query them, so you don't have to write your own editor before you can test your engine. And best of all, you can query it with SQL!
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
Dad, "Yea well I have a fan belt in street fighting"