I am currently making an XNA game in C#. I want to increase health as the player level up. I am currently using this equation.
MaxHealth = Convert.ToInt32(100 * Math.Pow(1.17, level - 1));
Its fine before the first 20 levels, but afterwards the health starts to increase extremely fast:
Level 1: 100 Hp.
Level 20: 1.975 Hp.
Level 30: 9.493 Hp.
Level 40: 45.630 Hp.
Level 100: 658.546.089 Hp.
Level 109: Crash: value too big for an integer.
How should i create these growth algorithms, so that the growth of hit points pr. level, will increase slowly. This is just an example, if you know a better growth rate, I will be happy to know that too.
level 2: Hp = base health + 60 (Base health = 100)
level 3: Hp = base helath + 60 + 120
level 4: Hp = base helath + 60 + 120 + 180.
But the max health formular will run on every update/tick, so all this should happen in the same calculation.
Edit:
Thank you all for your input, I really appreciate it. But while away from the question, I found a solution myself. Thank you very much. The solution:
if (level < 35)
this.baseMaxHealth = Convert.ToInt32((vitality * 10) + Math.Pow(level, 2) * 4);
else
this.baseMaxHealth = Convert.ToInt32((vitality * (level - 25)) + Math.Pow(level, 2) * 4);
I added vitality as an upgrade you can spend skill points or something on
EDIT 2:
I improved the code a bit
if (level < 35)
this.baseMaxHealth = Convert.ToInt32((vitality * 10) + Math.Pow(level, 2) * 4);
else if (level > 125)
this.baseMaxHealth = Convert.ToInt32((vitality * 100) + Math.Pow(level, 2) * 4);
else
this.baseMaxHealth = Convert.ToInt32((vitality * (level - 25)) + Math.Pow(level, 2) * 4);