My mind is getting old...simple maths and percentages...
StormyStudio
United KingdomMember Posts: 3,989
PERCENTAGES
Ok, I'm feeling old and stupid and lazy...
I have an attribute game.targets_completed that will change from say 4 to 28 depending on the scene.
In my scene, as it is completed the number will go down to 0.
So if the number starts at 8, when it reaches 4 the level is 50% complete, when it reaches 2 it is 25%...0 it is 100%...
What maths/rule do I need to work out the percentage of completion.
In the tidiest of ways? (I'm sure there some cool way of doing it)
I guess I need to know the original value, so I'll add another attribute that knows this.
game.targets_original
And a place to keep the percentage that is worked out.
game.completion_percentage
e.g
Here goes my first guess, please correct me if its wrong:
Change attribute game.completion_percentage to
100/ (game.targets_original/game.targets.completed)
Also is there a way to limit the answer to whole numbers?... (I think I can choose the right attribute type to do this...)
Ok, its home time... so time to go home, bath the 1 year old, cook dinner, make polite chit chat with the mrs and get back on GameSalad in about 2 hours to carry on my 2 week game project...
Ok, I'm feeling old and stupid and lazy...
I have an attribute game.targets_completed that will change from say 4 to 28 depending on the scene.
In my scene, as it is completed the number will go down to 0.
So if the number starts at 8, when it reaches 4 the level is 50% complete, when it reaches 2 it is 25%...0 it is 100%...
What maths/rule do I need to work out the percentage of completion.
In the tidiest of ways? (I'm sure there some cool way of doing it)
I guess I need to know the original value, so I'll add another attribute that knows this.
game.targets_original
And a place to keep the percentage that is worked out.
game.completion_percentage
e.g
Here goes my first guess, please correct me if its wrong:
Change attribute game.completion_percentage to
100/ (game.targets_original/game.targets.completed)
Also is there a way to limit the answer to whole numbers?... (I think I can choose the right attribute type to do this...)
Ok, its home time... so time to go home, bath the 1 year old, cook dinner, make polite chit chat with the mrs and get back on GameSalad in about 2 hours to carry on my 2 week game project...
Comments