
-----------------------------------
gohan
Fri Apr 01, 2005 11:25 am

HELP!!! With the high score thingy...
-----------------------------------
I need help in making a high score board tht will hold 5 high scores... but first i need to know how to make the game hold the score, and update it if another player gets the high score...so PLZZZ
Anyone help!!!
Thank You very much.

-----------------------------------
jamonathin
Fri Apr 01, 2005 11:34 am


-----------------------------------
I first got the idea from a previous post that briefly explained a open, put and get, so I just put everything together and got this . . 

You first need to start with a default base: 

%Just so we have a base to work with 
var streamout : int 
var names : array 1 .. 10 of string 
var score : array 1 .. 10 of int % Juss so you don't have to use strint 
open : streamout, "top10", put 
for i : 1 .. 10 
    names (i) := "New001" 
    put : streamout, names (i) 
    score (i) := 1 
    put : streamout, score (i) 
end for 
close : streamout  


Now here's the actual "top10" part, it calculates the position of the newscore and what not. 
Code: 

%Now we can edit the base record 
var names : array 1 .. 10 of string 
var score : array 1 .. 10 of int 
var newname : string := "Dudeman" %Whatever the name is 
var newscore : int := 48 % whatever the score is 
var streamin, streamout : int 
open : streamin, "top10", get 
for i : 1 .. 10 
    get : streamin, names (i) 
    get : streamin, score (i) 
    locate (i, 1) 
    put names (i), " - ", score (i) %Displaying original Top10 
end for 
close : streamin 
for decreasing i : 10 .. 2 
    if newscore > score (i) and newscore  score (1) and i = 2 then 
        for decreasing q : 10 .. 2 
            score (q) := score (q - 1) 
            names (q) := names (q - 1) 
        end for 
        score (1) := newscore 
        names (1) := newname 
    end if 
end for 
open : streamout, "top10", put 
for i : 1 .. 10 
    put : streamout, names (i) 
    put : streamout, score (i) 
    locate (i, 1) %Displaying new Top10 
    put i, ". ", names (i) 
    locate (i, 15) 
    put " - ", score (i) 
end for 
close : streamout 
 
Check tutorials.

-----------------------------------
Mr. T
Wed Apr 06, 2005 10:01 pm


-----------------------------------
Did you by any chance get this from a post made by guttface?

-----------------------------------
jamonathin
Thu Apr 07, 2005 6:05 am


-----------------------------------
me? I don't remember, I remember it was a MOD, but it was a little bit ago, and i first used the concept for a record list we had to do for class, then i juss "applied" it to a top 10 high score.

-----------------------------------
Kyle
Sun Apr 24, 2005 8:36 pm


-----------------------------------
hmm this is cool. can i use this for my high score list for my year end game project please or no ?

-----------------------------------
mike200015
Mon Apr 25, 2005 4:46 pm


-----------------------------------
can u explain what this part means? like the open : ....  and the put : .. and the get :.. stuff?

-----------------------------------
Vertico
Mon Apr 25, 2005 7:07 pm


-----------------------------------
sure

open : streamin, "top10", get 

what this does is it opens another file called top10 and gets the information from within.


get : streamin, names (i) 
    get : streamin, score (i)


something like this gets the information from the file that was opened and stores the information. So the first line will be saved in the var names and the second will be saved in the var score. Im assuming u understand then vars are in arrays.



put : streamout, names (i) 
    put : streamout, score (i)
 

then this displays the same information that was saved into these varables early on the screen.

-----------------------------------
jamonathin
Tue Apr 26, 2005 6:15 am


-----------------------------------
Vertico's exactly right, this is just to help you understand what is being written.  You can use "top10" or "top10.txt", it doesn't reall matter, you can open both up in word pad anyways, but this is what the file will ook like after it gets written:
New001
1
New001
1
..... 10 of each

Whatever you're telling to get the first time through the for loop, is grabbing the "New001", and whatever thesecond thing is you're telling to grab in the for loop, gets the "1".
If you're wanting to add something else only once, such as a title, where it only needs to be written once, just have it be last, and put it after the for loop.

And btw, yes you can use this if you want Kyle, anyone can, as long as they understand it.
