Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I recently asked this question on how to calculate a level based on experience:

Algorithm for dynamically calculating a level based on experience points?

I am using the following calculation to determine the players level:

decimal experience = 1829;
decimal rawLevel = (decimal)(.06 * Math.Sqrt(experience));
decimal level = Math.Floor(rawLevel);

For my test, 1829 experience points equates to 2.56600857364117M, which I floor to level 2.

My question is, how can I figure out how many points it would take to get to the next level based off of the calculation above?

I know the next level is 3, so I would need to figure out how many points equate to level 3 so that I can find the difference. What formula would I use, given the constant .06 above?

Update: Solution:

int experience = 150777;
decimal rawLevel = (decimal)(.06 * Math.Sqrt(experience));
decimal level = Math.Floor(rawLevel);
decimal nextPoints = (decimal)Math.Pow((double)(level + 1) / 0.06, 2);
share|improve this question

1 Answer 1

up vote 4 down vote accepted

You just need to do the inverse calculations in the inverse order :

Exp = (Level / 0.06)²

So for level 2, you would need 1111 exp, and for level 3 you would need 2500.

I wrote a small piece of code to see the exp needed for certain levels : the rounding isn't great it's not very nice for a player to see 'Next Level : 64944 Exp'.

What you could do is use a litte trick to make your level exp more 'rounded', just divide and then multiply by 10.

Code Exmaple Here!

share|improve this answer
    
Awesome. Works perfect! –  George Jun 17 '11 at 13:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.