Permanant High Scores

Started by Snake, Fri 19/10/2007 18:30:49

Previous topic - Next topic

Snake

I thought damn well I saw this module somewhere or someone was asking about a high scores screen. I can't find it. Did it even exist?

I need/would like a High Scores screen but don't know how I would make it permanent so every time you start the game, if you click on "High Scores" they would still be there.

I really thought there was a module for this...


--Snake
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

Ghost

wouldn't it be enough to write your scores to a file and display them in a
seperate GUI, or room? I don't recall there being a plud or mod for that, but the base functionality shouldn't be too hard to script.

Ashen

There's the IniFile module by RickJ (although I don't think it works with the newest AGS version), or the EncryptedFile module by HeirOfNorton (which I think does work). Niether are exactly what you're after, but both could do the same thing - use the File I/O functions to dump the scores to a file, to be read back later (like Ghost suggested). Even if they don't work as is, you should be able to figure out the necessary code from them.
The EncrytpedFile module also has the obvious advantage of encrypting the file, so the player can't just boost their scores in notepad.
I know what you're thinking ... Don't think that.

Snake

I wouldn't have the foggiest idea where to start writing a high scores script from scratch. Yeah, I could display the score in a seperate room (a monkey with ADHD could do that) but writing multiple scores in chronological order (while being able to allow the player to write a nickname) is confusing for me.

How would I go about writing it? And yeah, good point about having it so the player can't write their own scores in notepad. I want to keep that in mind.


--Snake
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

monkey0506

Quote from: Snake on Fri 19/10/2007 19:31:18a monkey with ADHD could do that

Talking about me behind my back again, eh?

I actually once started on a module for this...but I abandoned it long ago because I wasn't sure what all features anyone would want...and I personally wouldn't have much use for it.

Dualnames

It's not so hard to script actually.
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)

macon

I Think the post you are refering to was for my game 'Amotos Puf'. Rocco asked me if I could create a module for a high score table as he needed one for his game. I didn't write a module but I gave him the relevant scripts. The download link is below if you want it?

The high score table is actually a room file that is called whenever you need to view or enter a score in the table. I have included documentation, commented the code and included a room to test the table. It is coded in AGS 2.72.

Download here

Hope it helps.

Andy

Snake

QuoteIt's not so hard to script actually.
Well, thanks, Jim,  for ah, helping me out  ;D

Monkey: Hardily Hoodily Hoo, I point fun at you!!1!

Macon: I'll certainly give that a look and try it out! Thank you. I knew I saw it somewhere so that must be it.

I'll give it a try!
Thanks again,


--Snake
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

Dualnames

Sorry snake you want me to make an example code for you?
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)

Snake

Jim: Hehe :) Yeah, go ahead. I'd love to see it. I was thinking about trying to do it myself from scratch just to see if I could. I always seem to figure things out after I've posted about them.


--Snake
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

frission

Quote from: Snake on Fri 19/10/2007 19:31:18
I wouldn't have the foggiest idea where to start writing a high scores script from scratch. Yeah, I could display the score in a seperate room (a monkey with ADHD could do that) but writing multiple scores in chronological order (while being able to allow the player to write a nickname) is confusing for me.

Usually high scores are just in order of the scoring, not chronological.

Break the problem into smaller parts:

1. You need to be able to read and write to a file. You need to be able to store numerical data (the score) and textual data (the nickname).

2. You need to be able to sort scores in order of value. I don't have my AGS help manual open in front of me, but there is no doubt some way to sort things. (If there isn't, well -- you'd need to write your own sorting function. But for only 10 numbers or so that is pretty simple.)

3. You need to check if the current score (at the end of the game) is more than the smaller high score, and then ask for the nickname, and then see where it fits into the list of high scores, and then write it to the file.

Think about the format you want to use (try it unencrypted first), look at the help file functions for reading/writing files, and it should become more clear how to write the sort of thing you want to write. The best way to learn about programming is to try it yourself, and the best way to tackle any programming problem is to break it into small and discrete chunks! :-)

Radiant

1 is easy.

Read the manual on File.Open, File.Read, File.Write, and File.Close. Experiment.

You'll need an array of sorts:

Code: ags

int score[5];
string name[5];

function WriteScores () {
  int i;
  File *f = File.Open ("scores.dat");
  if (f) {
    while (i < 5) {
       f.WriteInt (score[i]);
       f.WriteString (name[i]);
       i++;
    }
    f.Close ();
  }
}


Sorting is easiest done like this:

Code: ags

function SortScore () {
  int i, j;
  while (i < 5) {
    j = i + 1;
    while (j < 5) {
      if (score[i] < score[j]) {
        int q = score[i];
        score[i] = score[j];
        score[j] = q;
        // swap strings likewise
      }
      j++;
    }
    i++;
  }
}


3 is done by comparing the current score to score[4].

Dualnames

Damn you Radiant. Stole my glory.... ::)
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)

SMF spam blocked by CleanTalk