-
I made a game that has a health thing that if something bad happens then percentage is deducted but when when something good happens then percentage is added. But the problem is that the pecentage is going over 100 and I want it to stay 100 or under how do I do that. The health variable is named inthealth <-- its an Integer
-
You can change the inthealt var to a property get/let var:
Dim inthealthProp ' and let this be the real one
Property get inthealth ()
inthealth=inthealthProp
end property
Property let inhealth(newval)
inthealthProp=newval
if inthealthProp>100 then inthealthProp=100
end property
Hope this helps
-
Will this work for you?
Hi,
If you're adding points for good_health and bad_health then the formula:
((good_health - bad_health) / good_health) * 100
will never be above 100% unless bad_health goes negative, at which time I would guess you're dead.
Al.
-
when adding the health earned to the intHealth, just use the
line below or something like this:
intHealth = IIF(intHealth + plusHealth > 100, 100, intHealth + plusHealth)
hope this helps...:)
-
if iCurrentHealthPoints > iMaxHealthPoints then
iCurrentHealthPoints = iMaxHealthPoints
End if
iHealth = (iCurrentHealthPoints / iMaxHealthPoints) * 100