User Settings and High Scores

I'm asking a lot of questions here at once, but I was wondering, I wanted to know how to make an "options" screen where you can set the screen resolution, sound volume, etc, and when you press "OK" it records it in some kind of file and then sets the settings to your game. Then when you reload your game, it would use these settings again because they were saved. That's my goal. Then I was wondering how you could save high scores in a file, then have them displayed, and announce when you beat the high score, etc. If you guys could help, that would be great. Thanks.


A pretty easy way for all of this:

You can also use binary files, like for your high scores.

Neil Walker

My framework code does this. You store everything into an XML file and on loading it it sets up allegro for you (if you wish). It also has an auto save function so that if you change a settings, e.g. 'ScreenCaps.BufferType=TRIPLE', 'MyCustom->SetFloat("gravity",-9.8)', when you exit the system, they are saved back to the file without you having to code anything.

After changing any of the major graphics settings (like width/height/buffering/depth) you just call Framework->Restart() and it reinitialises everything.

Obviously you have to use my classes, which probably isn't what you wanted, but it does animations and graphics handling as well and you can get the framework to run in a timer based loop to control the whole game for you if you wish (you just pass in function pointers and it does the rest).

It'll be finished in a few days.

Or if you just wanted code for all the settings and custom values like high-scores and don't mind c++ then download the stuff from my sig and it is all in the one file (Configurator), complete with help file, just ignore the bit about animations and graphics.


For settings a simple 'blah=fubar' system seperated by lines works for me. If that scares you you could check out the config routines linked to.

For highscores, I'd say use allegro's xor packfile password routines and write out in some obscure binary format, while linking against allegro staticly.

Thread #563019. Printed from