Hi Nina,
Yes, my initial values are also:
int correctAnswers = 0;
int questionsSeen = 0;
But the dummy text we put in the Score TextmeshPro box is set to “Score: 100%”
This text is only ever overwritten when we run:
scoreText.text = "Score: " + scoreKeeper.CalculateScore() + “%”;
But these only run when we make a selection.
Even your suggested Debug.Log:
Blockquote
public int CalculateScore()
{
int score = Mathf.RoundToInt(correctAnswers / (float)questionsSeen * 100);
Debug.Log(Time.frameCount + " — Score: " + score);
return score;
}
Would not run if we don’t make any selections during the game.
I.e. we do not have a method to calculate score if we run out of time for example.
So theoretically we can start the game, make no selection the entire game, and it will have “Score: 100%” being displayed the entire time.
Then when the game ends we run:
endScreen.ShowFinalScore();
Which will finally calculate the score to be 0%.
If we wanted to calculate score when the timer runs out would we put
scoreText.text = "Score: " + scoreKeeper.CalculateScore() + “%”;
In the else block of the DisplayAnswer(int index) method?