I was looking for hi-score example but I didn't find suitable. Let's imagine that there are X amount of players playing a game and everyone has certain amount of score. The mission is to list all the names and scores from the best to the lowest. Could someone make an example of this?
If the example helps me I will put the name to the Credits of my game...
This can be done by storing names and score in an ini or similar file
You then have 2 seperate list objects, one containing names, one containing scores, each listed in the order they appear in the ini.
When sorting the scores, you will need to use a fastloop
When running the loop you compare the top score to the score next in line.
If it's higher or the same, move down to the next line (store the current line number in a counter or something)
Compare this line to the next line and if it's lower, move down etc etc
Whilst moving scores down, remember to remove names down at the same time, i.e if you move a score down, move the corresponding name down
but these arent in order
The first score is 100, the second score is 120, as the first score is lower, move it down
Therefore the first iteration gives
120
100
99
Now, we moved a line, so update a flag or something to say that an item has been moved, this means another iteration is needed to continue ordering
As 100>99, nothing is needed to move
therefore after 1 iteration, we have
120
100
99
But as we have a flag saying a line was moved, we will need to do another run-through (making sure to reset the flag and line counter)
120 > 100, nothing needed to move, move down to next line
100>99 nothing needed to move, 99 is the last line so we check the flag, which is off, thus the ordering is complete
Assuming you've moved names down as well, we should have
Jim - 120
Bob - 100
Ben -99
I would make an example but i dont have TGF/MMF of any variety, sorry.