HLVSPL/highscore.cb

76 lines
1.3 KiB
Text
Raw Normal View History

2022-07-23 10:58:34 +03:00
Type hslist
Field nimi$
Field pisteet
EndType
Function highscore()
//Ladataan pisteet
loadhs()
//Estet<65><74>n v<>lit<69>n poistuminen
ClearKeys
ClearMouse
//Silmukka
Repeat
If GetKey() > 0 Or GetMouse() > 0 Then Exit
ClearText
//Otsikko
AddText "10 viimeisint<6E> tulosta:"
//Loppujen sijoitus
Locate 20, 20
//Lis<69>t<EFBFBD><74>n pisteet n<>yt<79>lle
i = 1
For hs.hslist = Each hslist
AddText Str(i) + ". " + hs\nimi + ": " + Str(hs\pisteet)
i = i + 1
Next hs
//Viel<65> n<>yt<79>n piirto
DrawScreen
Forever
//N<>yt<79>n tyhj<68>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