How Do I Make A High Score System?

BlitzPlus Forums/BlitzPlus Beginners Area/How Do I Make A High Score System?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Ok, ill give it a try. Im not great with the write/read routines though.
EDIT:
Erm...No savegames and levels...confused...help...:(
EDIT 2:
Fixed it to some extent,just need to display it at the title screen. could I have a hint on that(was no function for displaying in code.)
EDIT 3:
MAV.
	Dim Highscore_Name$(10)
	Dim Highscore_Score(10)
	Dim Highscore_Whacks(10)


; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; This function checks the player's current score against the high score list and inserts their name into the list if they have achived a new high score.
; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Function Update_Highscores()

	Local Loop, Loop2

	Load_Highscores()

	; Loop through the highscore list from the highest score to the lowest.	
	For Loop = 0 To 9
	
		; If this player's score is greater than the highscore at this location in the list...
		If highwhacks > Highscore_Score(Loop)
			
			; Move each highscore, starting at this one, down by one, pushing the last one off the list.
			
				For Loop2 = Loop To 8					
				
					Highscore_Name$(Loop2+1) = Highscore_Name$(Loop2)
					Highscore_Score(Loop2+1) = Highscore_Score(Loop2)
					Highscore_Whacks(Loop2+1) = Highscore_Whacks(Loop2)
					
				Next

			; Add this player's score to the list at this location.
			;
			; We use the score and level variables instead of the saved score because we want the score in the middle of the level to be saved, not the score
			; at the end of the last level.  This score will not have the level bonus added.  The player only gets that if they complete the level.

				Highscore_Name$(Loop) = Input$("What Is your name?")
				Highscore_Score(Loop) = player\score
				Highscore_Whacks(Loop) = whackshigh

			; Exit the loop early.
				Exit
			
		EndIf

	Next	
	
	Save_Highscores()
		
End Function


; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; This function loads the current high score data.
; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Function Load_Highscores()

	Local Filename$
	Local DataFile
	Local Loop

	; Attempt to open the data file for reading.
	; If the operation fails, no data will be loaded, but this will just result in no high scores being displayed, so no biggie.

		Filename$ = DATA_PATH$ + "highscores.dat"
		DataFile = ReadFile(Filename$)

	; Load the data.
	
		For Loop = 0 To 9
			
			Highscore_Name$(Loop) = ReadLine$(DataFile)
			Highscore_Score(Loop) = ReadLine$(DataFile)
			Highscore_Whacks(Loop) = ReadLine$(DataFile)
			
		Next
	
	; Close the data file.
		CloseFile DataFile
	
End Function


; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; This function deletes any high score file that exists and then saves a new one with the current high score data.
; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Function Save_Highscores()

	Local Filename$
	Local DataFile
	Local Loop

	; Attempt to open the data file for reading.

		Filename$ = DATA_PATH$ + "highscores.dat"
		If FileType(Filename$) = 1 Then DeleteFile Filename$

		DataFile = WriteFile(Filename$)

	; Write the data.
	
		For Loop = 0 To 9
			
			WriteLine(DataFile, Highscore_Name$(Loop))
			WriteLine(DataFile, Highscore_Score(Loop))
			WriteLine(DataFile, Highscore_Whacks(Loop))
			
		Next
	
	; Close the data file.
		CloseFile DataFile

End Function

Function DisplayHighscores()
Local textloop
Load_Highscores()

For textloop = 0 To 9

Print Highscore_Name$(textloop)
Print Highscore_Score(textloop)
Print Highscore_Whacks(textloop)

Next

End Function