75 lines
1.3 KiB
Text
75 lines
1.3 KiB
Text
Type hslist
|
|
Field nimi$
|
|
Field pisteet
|
|
EndType
|
|
|
|
Function highscore()
|
|
//Ladataan pisteet
|
|
loadhs()
|
|
|
|
//Estetään välitön poistuminen
|
|
ClearKeys
|
|
ClearMouse
|
|
|
|
//Silmukka
|
|
Repeat
|
|
If GetKey() > 0 Or GetMouse() > 0 Then Exit
|
|
|
|
ClearText
|
|
|
|
//Otsikko
|
|
AddText "10 viimeisintä tulosta:"
|
|
|
|
//Loppujen sijoitus
|
|
Locate 20, 20
|
|
|
|
//Lisätään pisteet näytölle
|
|
i = 1
|
|
For hs.hslist = Each hslist
|
|
AddText Str(i) + ". " + hs\nimi + ": " + Str(hs\pisteet)
|
|
i = i + 1
|
|
Next hs
|
|
|
|
//Vielä näytön piirto
|
|
DrawScreen
|
|
Forever
|
|
|
|
//Näytön tyhjäys ja tahattoman klikkauksen esto
|
|
PlaySound btthit
|
|
ClearText
|
|
ClearKeys
|
|
ClearMouse
|
|
EndFunction
|
|
|
|
Function loadhs()
|
|
//Alustetaan pistelista
|
|
For hs.hslist = Each hslist
|
|
Delete hs
|
|
Next hs
|
|
|
|
//Ladataan pisteet listaan
|
|
file = OpenToEdit("HighScore")
|
|
For i = 1 To 10
|
|
hs.hslist = New(hslist)
|
|
hs\nimi = ReadLine(file)
|
|
hs\pisteet = ReadLine(file)
|
|
Next i
|
|
|
|
//Suljetaan tiedosto
|
|
CloseFile file
|
|
EndFunction
|
|
|
|
Function lisaahs(name$, score)
|
|
loadhs()
|
|
nhs.hslist = New(hslist)
|
|
nhs\nimi = name
|
|
nhs\pisteet = score
|
|
Insert nhs, First(hslist)
|
|
Delete Last(hslist)
|
|
file = OpenToWrite("highscore")
|
|
For hs.hslist = Each hslist
|
|
WriteLine file, hs\nimi
|
|
WriteLine file, hs\PIsteet
|
|
Next hs
|
|
CloseFile file
|
|
EndFunction
|