I want to give an extra life bonus each time a player has reach a score more than 100,000, 200,000 and so on. How to calculate this?
The first thing that comes to mind is a separate Variable to which you add your limits. So...
ExtraVariable = 10000
If Points > ExtraVariable --- Add extra life, Extravariable = Extravariable + 10000
This way every time the score jumps over the limit you give an extra life and raise the limit.
Yea, that works. Thanks
Develop games in your browser. Powerful, performant & highly capable.
if SCORE % 100000 = 0 add 1 to LIVES
Bruno, wouldn't that only work with exact increments?
Yep. You're right. My fault. Duh!
Actually, Bruno's solution is efficient, if the score point is only +10000, so it will hit the increment 100.000, 200.000, etc.
And somebody's solution is great for score point that is vary.
My solution also overcomes possible lag issues, etc where there's a chance of "skipping" the exact figure. Modulus was the first thought here as well, but then I thought "what if he score isn't perfect" - hence that solution.
Yep. i'd go with Somebody 's solution.
I was going say make a variable of 100,000, every point subtracts 1 from that variable. When it hits 0 add one to lives reset variable.