DriverGame/DriverGame/DriverGame.cs
/// <summary>
/// Check to see what the best high score is.  If this beats it, 
/// store the index, and ask for a name
/// </summary>
Check to see what the best high score is.  If this beats it,
store the index, and ask for a name
Check to see what the best high score is . If this beats it store the index and ask for a name
private void CheckHighScore()
        {
            int index = -1;
            for (int i = highScores.Length - 1; i >= 0; i--)
            {
                if (score >= highScores[i].Score) 
                {
                    index = i;
                }
            }
            if (index >= 0)
            {
                for (int i = highScores.Length - 1; i > index; i--)
                {
                    highScores[i] = highScores[i - 1];
                }
                highScores[index].Score = score;
                highScores[index].Name = Input.InputBox("You got a high score!!",
                    "Please enter your name.", defaultHighScoreName);
            }
        }
private void CheckHighScore ( ) { int index = - 1 ; for ( int i = highScores . Length - 1 ; i >= 0 ; i -- ) { if ( score >= highScores [ i ] . Score ) { index = i ; } } if ( index >= 0 ) { for ( int i = highScores . Length - 1 ; i > index ; i -- ) { highScores [ i ] = highScores [ i - 1 ] ; } highScores [ index ] . Score = score ; highScores [ index ] . Name = Input . InputBox ( " " , " " , defaultHighScoreName ) ; } }
Check to see what the best high score is.
Check to see what the best high score is .
// We beat this score // We beat the score if index is greater than 0 // Move each existing score down one