How do I create custom file types (eg: **.tpw)
How do I create custom file types (eg: **.tpw)
TOO LITTLE INFORMATION, problem is unsolvable.....
neeeeeed more info........
My Avatar says: "Stay in School"
Rocco is the Boy!
"SHUT YOUR LIPS..."
I get what you mean. Basically, you can use any format in your file, and then give it an extension, finally register the extension with your program.
How would I create the file format and register it with my program.
Lets say you wanted to make a graphics file format for use in your game. You want to call it *.fmt. So all you do is make the file like normal ( using file streams ) then just write to it in a pre-determined format. For instance you might have your format like this. ( kind of like bitmap )
--------------------
IDENTIFIER ( First 2 bytes special so you can tell if this is your file format! )
INFO HEADER ( description about image )
PALETTE ( if applicable )
PIXEL DATA ( all the pixel info )
--------------------
Your identifier can be any length. 2 Bytes is usually good though. Just pick any 2 characters you want to associate with your type. Bitmap uses BM. That way if you read a file and it doesn't have your 2 byte identifier you know it is NOT valid.
Your header keeps information about the image. You want to store height, width, bits per pixel, compression schemes, number of bytes until pixel data, etc. Look up BITMAPFILEHEADER and BITMAPINFOHEADER for my ideas.
The palette is for low color count images. You can read more about them later or diregard them entirely if you want to use 16, 24, 32bpp.
Finally comes the actual pixel data. Remember this is stored in Little Endian format on Intel processors so it would be BGR instead of RGB for the component colors.
This is just an arbitrary file format based off of bitmap. You can easily see how you could write your own format for levels, scripts or anything! Have Fun!
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
ok i got that but lets say i wanted my own save file for the players that stores their sava data how would i do that.
You would just need to write out their information to the file. Just remember in what order you write them to and then read them in when loading. If you understand C/C++ like you claim, file I/O should be no match for you.