Okay, so I'm kind of upset that neither of you are actually reading any of my posts, when I'm trying to help. But I'll try to explain this for a 5 year old and then I'm done here.
My understanding is that global.extraLifeEvery
is a value that indicated how many points you need to get an extra life (like 100 coins in Mario). So let us say that value is 100
.
The global.score
is your current score, and prevScore
is the last score since you last got an extra life. Let's say that the current score is 350
and the previous score is 200
(since we are giving extra lives every 100 points).
Your logic is this:
if int(float(global.score) / global.extraLifeEvery)) > int(float(prevScore) / global.extraLifeEvery)):
If we plug in the numbers, it makes this:
if int(float(350) / 100)) > int(float(200) / 100)):
Now if we do the cast and division (since a float and an int will promote to float:
if int(350.0 / 100.0)) > int(200.0 / 100.0)):
if int(3.5) > int(2.0)):
Cast to int:
if 3 > 2:
So, it's true, which is technically correct. But it's confusing and obtuse logic.
What you are describing is a score that is above a threshold, which is the amount you need for an extra life above the previous score. Which is easily described with this inequality:
if global.score - prevScore > global.extraLifeEvery:
if 350 - 200 > 100:
if 150 > 100:
Which is true and more accurate describes what you are meaning to check for, with no unneeded division or multiple casts. Hope that makes sense.