How sound and graphics are stored

Started by
6 comments, last by darookie 19 years, 6 months ago
Hi i want to get into game programming, and want to start with a litle "Dogs of War" style game (2d game, top view, simple...) But i want to do the whole thing, animations, sound, ... Anyway, i want to use SDL, cause i already played around with it, made animations, sounds, network stuff, and now i wonder how to store and manage my sound and graphic files. In sdl there are realy easy to use functions, which one can load single graphic files, and sound files. I can image to use single sound files, cause there wont be so many sounds in this game, but what about the grapfics? I think it would be quite slow and painfull to load all graphics from their own bmp file. I mean all commercial games, have their data files (Quake=pak) where they store all there stuff. Are there any good articles about this topic? i found none in the aticle section. Has someone a good web address or knows a good book about this? Or maybe even has experince in using SDL in "big" games, where u cant load all graphics from singl graphic files. thx for any answer
Advertisement
Games like Quake3 and Doom3 load their data from .pk3 or .pk4 files - these are actually just .zip files with a funny extension.
It is probably faster to have each image/sound file as a separate file, but of you really wanted to create a single file format I guess the easiest would be the "file name" in the WAD, then a zero, then the file size, then the data. Then you'd have the next file after that... and when you want to load your file you export it from the WAD then load the exported file.
You can get libraries which handle this for you - zip files are the easiest to create yourself, I guess.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

I wrote some tutorials on this very subject, last week. You should probably read them in this order:

Custom Resource Files
Displaying a Bitmap from a Custom Resource File using SDL_RWops
Playing a WAV Sound from a Custom Resource File using SDL_RWops

Those will teach you how to store your bitmaps and WAVs into "pak" files, and use SDL to extract the info and use it in a game.

Hope that helps!


Ryan
--Visit the Game Programming Wiki!
I load all my data from individual PNG image files. Numbering them sequentially and with liberal use of the sprintf command, you can usually cut out most of the typing work to a small loop and 3-4 lines of loader code. :)

I was considering using sprite strips, but I'm too lazy to consider the advantages of such, and definitely way too lazy to implement that functionality.
I use simple ASCII text files with .dat extensions to load all my game assets. It's really simple and really fast to implement. The only problem of course is that since they aren't binary files, people can read them. But (1) if they mess with these files they'll only screw up the game and (2) using something like MoleBox will ensure they don't see them at all anyways.

Drew Sikora
Executive Producer
GameDev.net

ive used a hex editor and just merged files to each other, so i would basically load up 2 files and paste 1 file to the end of the other and save the new file.
Oh yea, Game Programming Gems 4 also has a nice article on using a fast version of XML to load game data. It's worth checking out - just take notes at the bookstore.

Drew Sikora
Executive Producer
GameDev.net

Quote:Original post by ekrax
ive used a hex editor and just merged files to each other, so i would basically load up 2 files and paste 1 file to the end of the other and save the new file.

From the command prompt:
 copy /b file_1+file_2+file_3+...+file_n all_files 

does exactly the same (on Windows, that is). No need for hex editing.
This method is simple and not very useful - you would have to store the file offets (and maybe sizes for convinience). A ZIP archive is way better for that.

This topic is closed to new replies.

Advertisement