[RESOLVED] [VB.Net] Game Scoring System - How can I Do This?
Hi,
I was just wondering, how can i create a scoring for system for my Maths quiz game made using VB.
My quiz game can generate automatic numbers / questions and shows a message box whenever the user gets the answer right or wrong. i.e.
when the user presses the check answer button, a message appears stating that he/she go it right or wrong. Then the user can press the next question button to get a new question.
Although now i need a scoring system which have no idea how to create :(
im totally lost :ehh:
Thanks
Re: [VB.Net] Game Scoring System - How can I Do This?
well, how much is a correct question worth? do you lose points if you get one wrong? is there a target score to go to a different "level", or a neverending cumulating score? do the point values increase as you go on?
we need more info.
it's pretty easy to do, but you need to give us some more detailed information.
vb.net Code:
Dim score as Integer = 0
If answer Then
score += 1
Else
score -= 1
End if
Re: [VB.Net] Game Scoring System - How can I Do This?
heres my code
Code:
Dim score As Integer = 0
TextBox2.Text = score
If Decimal.TryParse(TextBox1.Text, userAnswer) Then
If answer = userAnswer Then
score += 1
MsgBox("Congrats")
for some reason it just wont work.
Re: [VB.Net] Game Scoring System - How can I Do This?
Quote:
Originally Posted by
stateofidleness
well, how much is a correct question worth? do you lose points if you get one wrong? is there a target score to go to a different "level", or a neverending cumulating score? do the point values increase as you go on?
we need more info.
it's pretty easy to do, but you need to give us some more detailed information.
There are 10 questions in total (im not quite show how to only generate 10 as it just generates random forumales)
Each question is worth 1 point
There is no target sscore to go to a particular level; a message box will only appear stating congrats you got X mark out of 10 or something.
Re: [VB.Net] Game Scoring System - How can I Do This?
Re: [VB.Net] Game Scoring System - How can I Do This?
Maybe it is because you're initializing the score in the same procedure that you're adding it to?
I am assuming the snippet you posted is from the "Check Answer" [or something like that] button's Click event handler.
Here's how I would go about it:
Code:
'Declarations
Private score As Integer = 0
Private userAnswer As Decimal
'...Form Initialization Code...
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If Decimal.TryParse(TextBox1.Text, userAnswer) Then
If answer = userAnswer Then
score += 1
TextBox2.Text = score
MsgBox("Congrats")
Else
MsgBox("Incorrect Answer")
End If
End If
End Sub
Re: [VB.Net] Game Scoring System - How can I Do This?
Quote:
Originally Posted by
garyjohn_2000
Here's how I would go about it:
OMG Thankyou it worked :)
1 more question
does anyone now how to implement a reset feature for example when the user does about 10 questions a message box appears stating that the user either has them all correct or has some wrong then it resets the counter, so that the user can start again.
cause currently the questions are infinite lol
thanks
edit: incase my explanation doesnt make sense, i provided a peice of code that boviously doesnt work (but i hope you get the general idea of what i mean :) )
Code:
If Button2.pressed = 10 Then
msgbox = scoreresult else
Reset(score)
Re: [VB.Net] Game Scoring System - How can I Do This?
well what I would do is on form load call a "question generating" sub that would generate 10 questions with a for loop:
for x as Integer = 0 to 9
'create a question
'store it in an array at index i
next
Each time a question is asked, increment a questionCount variable by 1
then in the button's Click Event, you would check to see if questionCount = 10, if so, then call your msgbox.
to reset the score, just set the playersScore = 0 and call your "question generating" sub again.
Re: [RESOLVED] [VB.Net] Game Scoring System - How can I Do This?
the simplest can be is
if the answer is "dog" then
Quote:
If Textbox1.Text = "dog" then
Score.Text = Score.Text + 1
else
// What ever you want :P
// Can be..
Score.Text = Score.Text - 1
End if