Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How do I make a High Score table?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
born130




PostPosted: Fri Jun 06, 2003 4:00 pm   Post subject: How do I make a High Score table?

Hello,

I wanted to know how I could make a high score table in my game.

For example if the user breaks the record say 9.68 seconds, it will "save" this number as the new record to beat. Just like an arcade game.

Some people say i should use a text file?

Any help is appreciated.
thanks
Sponsor
Sponsor
Sponsor
sponsor
hello




PostPosted: Fri Jun 06, 2003 4:13 pm   Post subject: (No subject)

u should use a textfile to store the scores or times

then when u get a new time or score

check if the tenth score or time in the textfile is smaller or greater then the inputed one

and if its watever (greater or smaller)

then replace the tenth score with the inputted score

and then
start check in a decreasing loop
if the ninth score is watever to the inputed one that is tenth
and if watever switch them
born130




PostPosted: Fri Jun 06, 2003 4:15 pm   Post subject: (No subject)

show example
Tony




PostPosted: Fri Jun 06, 2003 7:06 pm   Post subject: (No subject)

open : fileName, fileNum : get
get fileNum, tempValue

if scrore > tempValue then
open : fileName, fileNum2 : put
put fileNum, score
end if

/\ something like that... I'm not sure of the syntax though, didnt use that in a long time
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
JSBN




PostPosted: Fri Jun 06, 2003 7:50 pm   Post subject: (No subject)

code:

var filenum,score,highscore : int
open: filenum,"Highscores.txt" get
get: filenum, highscore
close : filenum

if score > highscore then
open: filenum,"Highscores.txt" put
put: filenum, score
close : filenum
end if

That should be what you are looking for.
naoki




PostPosted: Fri Jun 06, 2003 7:56 pm   Post subject: (No subject)

make 2 arrays : 1 to hold the name, 1 to hold the score
loop and read all the names and scores from a textfile, storing them into the array

afterwards loop again and see if the new score beats any of'em. if it does then delete last score and name and move every entry down 1, putting new score in its appropriate place

then loop again and write it all into the textfile.
Andy




PostPosted: Fri Jun 06, 2003 9:23 pm   Post subject: (No subject)

born130, you know you can just call me and ask me or ask me at school eh? instead of having hang helping you... jk
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: