Execute and action when passing a certain value

HunterMetroid64

New member
Joined
Apr 22, 2009
Messages
1
Programming Experience
Beginner
I'm making a simple game as my first personal Visual Basic program, and I've run into a small problem. I'm trying to make it so when you reach or pass certain amounts of experience, you receive 5 stat points, but the best I've been able to do so far is have the program add the points when you are in a small window of 2 values. This is what I have now:

If Val(lblTtlExp.Text) >= 100 And Val(lblTtlExp.Text) < 110 Then
lblStats.Text = Val(lblStats.Text) + 5
ElseIf Val(lblTtlExp.Text) >= 200 And Val(lblTtlExp.Text) < 210 Then
lblStats.Text = Val(lblStats.Text) + 5
ElseIf Val(lblTtlExp.Text) >= 300 And Val(lblTtlExp.Text) < 310 Then
lblStats.Text = Val(lblStats.Text) + 5
End If
 
I'm not quite sure I understand your problem but I can give you a little help. One issue that is fairly common in games, more so dealing with animating graphics, is that you are increasing lblTtlExp.Text faster than your bounds checking.

Meaning you check the value of your EXP once and it is 99. You will not gain the extra 5 stat points. Then you do some action and your EXP increases to 110. In this case you never actually fall in that range, you just jump right over it.

If this does end up being the issue you may want to rethink how you are awarding those bonuses. Ultimately you could skip the bonus like i've showed. And you could get the bonus multiple times. Just depends if the amount of EXP you can gain in one action will always be the same or if it differs between actions.

I'm not sure that helps but might be something to look out for.
 
Back
Top