4 Replies Latest reply on Apr 18, 2006 5:25 PM by Meekle

    High Scores

      Hi can anyone help please -
      I'm currently making a game for an assignment, which is pretty much finished however I have to include a score recording system which will record name, score and number of hits for the top 10 players. The scores should be held in an external text file . I was wondering if anyone could explain a simple way to do this, i know i should use getpref and setpref to create and load the text file, and also use some sort of list. If i use a property list i can have a property 'name' and its value 'score' but how would i add a third element, the hits. Alternatively if i use a linear list, one for each of name, hits and score, how would i link them and sort them so that the correct name hits and score display together. Also i should probably mention that the game currently has name, hits and score held in global variables.

      If anyone could point me in the right direction that would be great, I'd really like to understand how to get this working first instead of just the usual trial and error.

        • 1. Re: High Scores
          Level 7
          The general tool for reading and writing text files is the fileIO xtra,
          implementing it involves some learning curve.

          The easy way to store user settings like high scores is the setPref,
          getPref functions which store text in a predefined location and works
          with shockwave, unlike fileIO xtra.

          The larger effort might be involved in getting the scores from the
          stored text version back to whatever variables scheme you store them in.

          value(somestring) converts a text representation of a number back to an
          integer or float.

          you can even store list variables as text

          x = [["bob", 123], ["Jim", 567], ["Sally", 778]]

          savePref "scoreFile", string(x)

          -- retrieved with

          x = value(getPref("scoreFile"))
          • 2. Re: High Scores
            M4rkeh Level 1
            thanks for that JB, I was hoping to stay away from fileIO as it hasn't been mentioned on my course. I had a thought that a could concantate the name and hits variables and enter them as the property and have the scores as the value in a property list. Then when retrieving them somehow separate the name and hits but that seemed overly complicated. I'm still not sure what to do
            • 3. Re: High Scores
              Level 7
              I think I showed an example saving a SINGLE property list with the
              simple savePref fucton.

              You might need a bi of code to parce the property list, converting the
              content to a display text table.
              • 4. Re: High Scores
                By any chance are you creating a 2D game and if you are are you baseing it on the FSO game created on a macromedia director as this is wot ure game sounds like, and if yes if this game goes up on to the internet may i now the website name where i may download the game to see what you have done with it