The Daily Click ::. Forums ::. Klik Coding Help ::. Local Hi-score with custom events
 

Post Reply  Post Oekaki 
 

Posted By Message

Jarzka



Registered
  26/12/2003
Points
  270

VIP Member
9th July, 2008 at 09:46:50 -

Hi.

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...

Image Edited by the Author.

 
n/a

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
9th July, 2008 at 11:25:45 -

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

Example:
your ini file looks like this

[unsorted]
name1=Bob
score1=100
name2=Jim
score2=120
name3=Ben
score3=99

the scores will be
100
120
99

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.

Image Edited by the Author.

 
My signature is never too big!!!

Jarzka



Registered
  26/12/2003
Points
  270

VIP Member
9th July, 2008 at 12:00:29 -

Hmm, sounds interesting but I'm not sure will it work Let's see.

 
n/a

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
9th July, 2008 at 13:39:07 -

if you're looking to do a hi-score board for an internet game, with on-line highscores, you'll need to use either php or asp, along with a database

 
My signature is never too big!!!

Jarzka



Registered
  26/12/2003
Points
  270

VIP Member
9th July, 2008 at 14:33:47 -

Hey, thanks a lot. I think it works now

Here is the link if someone else needs it:
http://www.ferror.net/temp/score_example.mfa
(If the link is offline, please send me a message)

 
n/a
   

Post Reply



 



Advertisement

Worth A Click