Advertisement
Roland-2

HighScore

Jul 14th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.54 KB | None | 0 0
  1.  Private Sub CheckForNewHighScore()
  2.         '------------------------------------------------------------------------------------------------------------------
  3.         ' Purpose: Check to see if player's score has beaten any of the top 5 scores, prompt player for their name if so
  4.         '------------------------------------------------------------------------------------------------------------------
  5.  
  6.         Dim i As Integer = 0
  7.         Dim j As Integer = 0
  8.  
  9.          '0 = 1 pos , 4 lowest
  10.  
  11.         If Score > Top5PlayerScore(4) Then
  12.  
  13.             '  timeBeginPeriod(0)
  14.             Dim showdialog As New frmNameEntry
  15.  
  16.             ' Get the position in Table
  17.             For i = 4 To 0 Step -1
  18.                 If Score > Top5PlayerScore(i) Then
  19.                     j += 1
  20.                 End If
  21.             Next
  22.             j = 5 - j
  23.  
  24.  
  25.             ' Prompt player for their name
  26.  
  27.             If showdialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
  28.  
  29.                 ' Sort table
  30.  
  31.  
  32.                 If j < 4 Then
  33.  
  34.                     For i = 4 To (j + 1) Step -1
  35.                         Top5PlayerName(i) = Top5PlayerName(i - 1)
  36.                         Top5PlayerScore(i) = Top5PlayerScore(i - 1)
  37.                     Next
  38.  
  39.                 End If
  40.  
  41.                 Top5PlayerName(j) = PlayerName
  42.                 Top5PlayerScore(j) = Score
  43.                 ' Add new player
  44.  
  45.                 SaveHighScores()
  46.              
  47.             End If
  48.  
  49.         End If
  50.  
  51.         AppRunning = False
  52.         MainLoop()
  53.  
  54.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement