Topic was automatically imported from the old Question2Answer platform.
Asked By
Idleman
I want the score system to add a live for player every 500 points, but I am not sure how to set this by using the if condition. Is there a way of setting for example if scores == every 500, then do something? Thank you.
var life : int = 3
var score : int = 0
var score_life : int = 0
const ADD_LIFE : int = 500
func add_score_1(add : int) -> void:
score += add
while score >= score_life + ADD_LIFE: # if you add more than 999 points, an if won't work
life += 1
score_life += ADD_LIFE # increase to match last score to get life
func add_score_2(add : int) -> void:
score += add
score_life += add
while score_life >= ADD_LIFE: # if you add more than 999 points, an if won't work
life += 1
score_life -= ADD_LIFE # keep score_life under ADD_LIFE
(untested)
Should be more or les self explanatory.
If not, feel free to ask.
Thank you for answering my question. I got a suggestion to try fposmod, and it works for me with less code involved.