Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Making a dynamic high scores table

by roboticus (Chancellor)
on Dec 01, 2012 at 17:20 UTC ( #1006617=note: print w/ replies, xml ) Need Help??

in reply to Making a dynamic high scores table


I'd suggest storing the high score list in a file so that when you restart the game, you still have the original values. So your subroutine to save & display high scores might be something like:

  1. Read high-score-list file
  2. Add new score, initials
  3. Sort list
  4. Display
  5. Write back new high-score-list to file

Optionally, if you want to keep only the top X scores, then after sorting, just write the first X items back to the new file. Also, to prevent a program problem from causing you to lose the entire list, write the new list to a different file. Once you're done, then you can rename the original to original.bak, and then rename the new file to the original name.


When your only tool is a hammer, all problems look like your thumb.

Comment on Re: Making a dynamic high scores table

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006617]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2015-11-27 13:35 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (729 votes), past polls