is there a way you can store a 'highest score' as in the real gaming machines?

Started by barefoot, Sat 11/06/2011 21:18:46

Previous topic - Next topic

barefoot

Hi

I'm presently looking around to find an answer / solution to this:

is there a way you can store a 'highest score' as in the real gaming machines...  Each time you run the game you see the highest score so far to beat and if you beat it the highest score changes and so on?

Also (while i'm at it):

MODULE: KeyboardMovement v1.02: have heard you can do diagonal (up right + up left keys).. This is what I would like to implement. Have you tried it?

All help / hints appreciated

barefoot


I May Not Be Perfect but I Have A Big Heart ..

Khris

You can store data in external files. Just look up File.Open/Close and File.ReadInt/WriteInt.

barefoot

I May Not Be Perfect but I Have A Big Heart ..

Matti

Quote from: barefoot on Sat 11/06/2011 21:18:46
MODULE: KeyboardMovement v1.02: have heard you can do diagonal (up right + up left keys).. This is what I would like to implement. Have you tried it?

Of course diagonal walking works, you don't need to implement anything.

barefoot

I May Not Be Perfect but I Have A Big Heart ..

Dualnames

Function Declaration:
Code: ags

enum Score {
  Get,
  Set, 
  Reset
};

import function HighScore(Score param, int hscore=-1);

Function
Code: ags

function HighScore(Score param, int hscore)
{
 if (param==Reset) 
{
   File.Delete("highscore.txt");
 }
 if (param==Get)
 {
   File *input = File.Open("highscore.txt", eFileRead);
    if (input != null) 
    {
    hscore = input.ReadInt();
    input.Close();
    Display("hscore is %d",hscore);
    return hscore;
    }
 }
 if (param==Set)
 {
 File *output = File.Open("highscore.txt", eFileWrite);
   if (output == null) 
   {
   Display("Error opening file.");
   }
   else 
   {
   output.WriteInt(hscore);
   output.Close();
   }
  }
}



How to Use?

HighScore(Set,200); //This will set the highscore to 200.
HighScore(Get); //This will get the current highscore.
HighScore(Reset); //This will reset the highscore.

Now if you want multiple highscores, I apologize, and I'll fix.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

monkey0506

Isn't there a module that does this? I think Rocco made one..pretty sure..coz I seem to recall commenting on my own unreleased module for the same thing.

I mean, doing it yourself is fine too, but there's no need to reinvent the wheel unless you (like me :P) just really, really enjoy doing so. :=

Edit: Apparently I didn't actually comment in the module's thread, the latest version of AGS that it's been verified to work with is 3.0.1, and without having used it I'm not sure how easy/difficult it might be to customize it to work with your own game (seems like it might be a rather basic module with little-to-no customization options)..but:

Rocco's Highscore Module

Dualnames

Quote from: monkey_05_06 on Sun 12/06/2011 22:51:42
Isn't there a module that does this? I think Rocco made one..pretty sure..coz I seem to recall commenting on my own unreleased module for the same thing.

I mean, doing it yourself is fine too, but there's no need to reinvent the wheel unless you (like me :P) just really, really enjoy doing so. :=

It was fun and it took me like 10 minutes :P
Can't a man have fun?!

I knew there's a highscore module, I recall someone even used it along with encrypted module or something, that you coded.

I have a feeling that there are more than one highscore modules though, but it may be just me.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

monkey0506

Quote from: DualnamE3 on Sun 12/06/2011 23:06:22Can't a man have fun?!

No! Don't you remember the quiz you took all those years ago when signing up for the forums? Having fun is against the forum rules. 8)

SMF spam blocked by CleanTalk