Saving And Loading High Scores


WarmFluffyUK

The Big Wad Bolf.
Joined
Sep 4, 2004
Messages
3,384
Location
UK
Website
www.retrotech.one
Hia,

I have high scores in an array

High_Scores[10][2];

And I want to save them to a file and load them in when the game starts, what's the quickest and easiest way to do this?

Clare.
 
the easiest way is to make a struct of what you want to save. then just write your struct ot the file (and read it from it).
there are a few posts about this on the forum already :)
 
Are you thinking of adding a feature like "Upload high scores to WarmFluffyUK's website" sometime in the future? if yes I guess you will need to complicate things a little bit more , just to avoid seeing people mess around with the high scores table.
 
the easiest way is to make a struct of what you want to save. then just write your struct ot the file (and read it from it).
there are a few posts about this on the forum already :)
Okay, not looked into structs before, I will do that :)

Are you thinking of adding a feature like "Upload high scores to WarmFluffyUK's website" sometime in the future? if yes I guess you will need to complicate things a little bit more , just to avoid seeing people mess around with the high scores table.
Actually I have thought about that, I would need some form of encryption, I have already written something like that in another project.

I guess I could save the high scores in one file, and the top score in another. The top score file is encrypted and can be loaded up to my website, PHP then decrypts it and adds it to the database :). Now all I got to do is learn about structs. And I need to know commands and syntax to save and load files, the Fenix FAQ isn't very clear, especially since it's badly translated :huh:

http://www.gp32x.de/board/index.php?s=&am...st&p=453861

Just replace those variables with the array.

- Alex
Hey Alex thanks hon, that's exactly what I needed :wub: . You just showed me how to use structs too :)
 
Last edited by a moderator:
Hi again,

Well I can't seem to get this to work, here's what I have done to see if I can get a program to save something.

Code:
Program TestSave;
Global
   struct Scores[2];
	  int Score;
	  string Name;
   end;

Begin
   Scores[1].Score=10;
   Scores[2].Score=20;
   Scores[1].Name="Clare";
   Scores[2].Name="Phil";
   Save("scores.sav", Scores);
   Frame;
End;
Any ideas why this is not working? It doesn't throw up any errors, but no file is created.
 
yup, in fenix, it starts at 0 (normally).
but if you allocate it, you allocate up to the given index, so myarray(5) declares an array ranging from 0 to 5, thus holding up to 6 variables....
i don't know if it's different with structs (would be weird). it's not a great system imo, but ofcourse lets you code for any way you're used to, without encountering problems (besides perhaps allocating a tiny bit too much memory)
 
yup, in fenix, it starts at 0 (normally).
but if you allocate it, you allocate up to the given index, so myarray(5) declares an array ranging from 0 to 5, thus holding up to 6 variables....
i don't know if it's different with structs (would be weird). it's not a great system imo, but ofcourse lets you code for any way you're used to, without encountering problems (besides perhaps allocating a tiny bit too much memory)
Well we all live and learn. And today I have learned that there's a little bug in the present GP2X version of Fenix that crashes the system when you are saving and loading structs and arrays that contain strings. I have to convert the strings to integers first :(. All working now though YAYYY :).

And this means that Myriad is almost complete!!!!!
 
Last edited by a moderator:
Back
Top