After building the library, you find a command line tool named sga in the tools directory.
This program is for creating encrypted data files that you can later use for loading your images, music, sprites and other files.
To create a archive file you use the following syntax:
./sga mysecretkey myfile.dat data/myimage.png data/mymusic.ogg data/mylogo.jpg
This will generate a file called myfile.dat holding all following files with filenames relative to the actual position and encrypting it with the password 'mysecretkey'
The files are encrypted by a simple XOR operation against the characters of your password. This is a very quick but weak encryption. Do not use it to store any extremly sensitive data, it is easy decryptable as soon as someone knows the password. So dont use any passwords like 'mysecretpassword' or something like that, the password will be clearly viewable in the binary executable of your game. It would be a wise choice to choose some text that is displayed somewhere in the game, so it is not so obvious.
The command has currently no sanity checks at all so it refuses to overwrite existing files as a protection against data loss though. wrong parameter calls. You'll have to remove the data file first to be able to update your data.
The resulting files may have any size (depending on the operating system your game runs on), they are not read completely into ram, only necessary ram for loading the named file is used.
First you have to open the file:
SGEFILE *myfile=sgeOpenFile("myfile.dat","mysecretkey");
Again, checking if the file open did work is not necessary, SGE will bail out if it fails.
You can then load your data with a range of available functions. Here are some examples, they should be pretty obvious what they are doing, for now, you need just to know that they load data from your archive, you'll get more details about this functions later:
SGESPRITE *mysprite=sgeSpriteNewFile(myfile, "data/myimage.png"); SGEANIMATEDSPRITE *myanimsprite=sgeAnimatedSpriteNewFileRange(myfile, "data/anim%04d.png", 1, 20); SGESOUND *mymusic=sgeSoundNew(myfile, "data/mymusic.ogg");
When you're done loading your data, you close the file with:
sgeCloseFile(myfile);