mcapone888
Member
- Joined
- Jun 17, 2011
- Messages
- 10
- Programming Experience
- Beginner
Hi everyone. I am a novice with VB.Net. I created a high score table for an educational game I created. The High Score table will show the top 5 highest test scores (as percentages). It includes the person's name, percent correct, and number of correct answers. The test is open ended so the person taking it can choose when they have answered enough questions.
OK. I am saving the three variables as arrays:
EasyName(4) as String
EasyPercentage(4) as Decimal
EasyNumberCorrect(4) as Integer
* "Easy" is in reference to the game level - not important.
The Arrays are saved having the EasyPercentage array contain the highest percentage in the 0 spot, and then the 1, 2, 3, and 4 spots have percentages going lower and lower (so the 0 spot is the best percentage).
When the test is done I compare their percent correct to the EasyPercentage array. I compare it against the first value (0). If it the current percent is
greater, I save it to this spot in the array and bump down all the values in the array (I also do this with the EasyName(4) and EasyNumberCorrect(4) array to keep them all in sync. If their current percent is not better than the value at array EasyPercentage(0), I move on to (1). So on and so on. I am using an If / End If tree for all of this. I know I should probably use a loop, but again, I am a novice (and loops scare me :crying
.
Anyway, this is all working great. I am also saving / loading the data from a text file.
My issue is many times (especially in Easy mode), all top five percentages are 100%. Once all five spots are 100%, no one else can make the top five as the EasyPercentage array has all 100's in all five spaces (meaning no one new percentage will ever be greater than 100%).
I decided I want to use the EasyNumberCorrect array as a tie breaker. Meaning if the top two percentages are 100, then whoever has the higher amount of correct answers (EasyNumberCorrect) gets listed in the top spot.
This is where i get confused. How should I do this? Should I make a change when I save the data to the arrays, or should I just make a change to the form which displays the high scores. Perhaps I should use a multi-dimensional arrays to store both the EasyPercentage and EasyNumberCorrect values?
Any suggestions would be appreciated. Thanks.
Here's how I am saving my data to the arrays after the game - this only runs if they have made a high score:
This is how I am displaying the data on the High Score form:
OK. I am saving the three variables as arrays:
EasyName(4) as String
EasyPercentage(4) as Decimal
EasyNumberCorrect(4) as Integer
* "Easy" is in reference to the game level - not important.
The Arrays are saved having the EasyPercentage array contain the highest percentage in the 0 spot, and then the 1, 2, 3, and 4 spots have percentages going lower and lower (so the 0 spot is the best percentage).
When the test is done I compare their percent correct to the EasyPercentage array. I compare it against the first value (0). If it the current percent is
greater, I save it to this spot in the array and bump down all the values in the array (I also do this with the EasyName(4) and EasyNumberCorrect(4) array to keep them all in sync. If their current percent is not better than the value at array EasyPercentage(0), I move on to (1). So on and so on. I am using an If / End If tree for all of this. I know I should probably use a loop, but again, I am a novice (and loops scare me :crying
Anyway, this is all working great. I am also saving / loading the data from a text file.
My issue is many times (especially in Easy mode), all top five percentages are 100%. Once all five spots are 100%, no one else can make the top five as the EasyPercentage array has all 100's in all five spaces (meaning no one new percentage will ever be greater than 100%).
I decided I want to use the EasyNumberCorrect array as a tie breaker. Meaning if the top two percentages are 100, then whoever has the higher amount of correct answers (EasyNumberCorrect) gets listed in the top spot.
This is where i get confused. How should I do this? Should I make a change when I save the data to the arrays, or should I just make a change to the form which displays the high scores. Perhaps I should use a multi-dimensional arrays to store both the EasyPercentage and EasyNumberCorrect values?
Any suggestions would be appreciated. Thanks.
Here's how I am saving my data to the arrays after the game - this only runs if they have made a high score:
VB.NET:
TempHighScoreName = Trim(txtName.Text)
TempHighScorePercentage = (CorrectTotal / TotalTotal) * 100
TempHighScoreNumberCorrect = CorrectTotal
If GameLevel = "Easy" Then
If TempHighScorePercentage > EasyPercentage(0) Then
EasyName(4) = EasyName(3)
EasyPercentage(4) = EasyPercentage(3)
EasyNumberCorrect(4) = EasyNumberCorrect(3)
EasyName(3) = EasyName(2)
EasyPercentage(3) = EasyPercentage(2)
EasyNumberCorrect(3) = EasyNumberCorrect(2)
EasyName(2) = EasyName(1)
EasyPercentage(2) = EasyPercentage(1)
EasyNumberCorrect(2) = EasyNumberCorrect(1)
EasyName(1) = EasyName(0)
EasyPercentage(1) = EasyPercentage(0)
EasyNumberCorrect(1) = EasyNumberCorrect(0)
EasyName(0) = TempHighScoreName
EasyPercentage(0) = TempHighScorePercentage
EasyNumberCorrect(0) = TempHighScoreNumberCorrect
ElseIf TempHighScorePercentage > EasyPercentage(1) Then
EasyName(4) = EasyName(3)
EasyPercentage(4) = EasyPercentage(3)
EasyNumberCorrect(4) = EasyNumberCorrect(3)
EasyName(3) = EasyName(2)
EasyPercentage(3) = EasyPercentage(2)
EasyNumberCorrect(3) = EasyNumberCorrect(2)
EasyName(2) = EasyName(1)
EasyPercentage(2) = EasyPercentage(1)
EasyNumberCorrect(2) = EasyNumberCorrect(1)
EasyName(1) = TempHighScoreName
EasyPercentage(1) = TempHighScorePercentage
EasyNumberCorrect(1) = TempHighScoreNumberCorrect
ElseIf TempHighScorePercentage > EasyPercentage(2) Then
EasyName(4) = EasyName(3)
EasyPercentage(4) = EasyPercentage(3)
EasyNumberCorrect(4) = EasyNumberCorrect(3)
EasyName(3) = EasyName(2)
EasyPercentage(3) = EasyPercentage(2)
EasyNumberCorrect(3) = EasyNumberCorrect(2)
EasyName(2) = TempHighScoreName
EasyPercentage(2) = TempHighScorePercentage
EasyNumberCorrect(2) = TempHighScoreNumberCorrect
ElseIf TempHighScorePercentage > EasyPercentage(3) Then
EasyName(4) = EasyName(3)
EasyPercentage(4) = EasyPercentage(3)
EasyNumberCorrect(4) = EasyNumberCorrect(3)
EasyName(3) = TempHighScoreName
EasyPercentage(3) = TempHighScorePercentage
EasyNumberCorrect(3) = TempHighScoreNumberCorrect
ElseIf TempHighScorePercentage > EasyPercentage(4) Then
EasyName(4) = TempHighScoreName
EasyPercentage(4) = TempHighScorePercentage
EasyNumberCorrect(4) = TempHighScoreNumberCorrect
End If
End If
End If
This is how I am displaying the data on the High Score form:
VB.NET:
[SIZE=2] lblEasyName0.Text = EasyName(0)
lblEasyPercentage0.Text = FormatNumber(EasyPercentage(0), 2) & [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"%"
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]lblEasyNumberCorrect0.Text = EasyNumberCorrect(0)
lblEasyName1.Text = EasyName(1)
lblEasyPercentage1.Text = FormatNumber(EasyPercentage(1), 2) & [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"%"
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]lblEasyNumberCorrect1.Text = EasyNumberCorrect(1)
lblEasyName2.Text = EasyName(2)
lblEasyPercentage2.Text = FormatNumber(EasyPercentage(2), 2) & [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"%"
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]lblEasyNumberCorrect2.Text = EasyNumberCorrect(2)
lblEasyName3.Text = EasyName(3)
lblEasyPercentage3.Text = FormatNumber(EasyPercentage(3), 2) & [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"%"
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]lblEasyNumberCorrect3.Text = EasyNumberCorrect(3)
lblEasyName4.Text = EasyName(4)
lblEasyPercentage4.Text = FormatNumber(EasyPercentage(4), 2) & [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"%"
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]lblEasyNumberCorrect4.Text = EasyNumberCorrect(4)
[/SIZE]