View Single Post
Old 07 June 2014, 21:11   #2
Graham Humphrey
Moderator
Graham Humphrey's Avatar
 
Join Date: Jul 2004
Location: Norwich, Norfolk, UK
Age: 35
Posts: 11,137
This is how I stored my high scores in my game Downfall - full source is on the site if you wish to take a peek

I set my scores to be stored in an array (holding 20 entries) which contained the name and the score of the player. The save routine only saved it if the scores had changed since the last load when the game was quit so you might not want to do it exactly the same way but hopefully it gives you a bit of an idea.

Code:
.loadhighscores

If OpenFile(0,"Data/downfall.highs")=-1 ; open our file if it exists
 For n=0 To 19
  Fields 0,highs(n)\name,highs(n)\score ; read all array data
 Next n
EndIf
Get 0,0 ; transfer data to array
CloseFile 0

Return

.savehighscores

AMIGA
If chg=1  ; If highscore file has changed
 dummy=OpenFile(0,"Data/downfall.highs") ; create new file, or overwrite existing one
 For n=0 To 19
  Fields 0,highs(n)\name,highs(n)\score  ; take all highscore array data
 Next n
 Put 0,0 ; write array data to our file
 CloseFile 0
EndIf

Return
Graham Humphrey is offline  
 
Page generated in 0.04739 seconds with 11 queries