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'm having trouble working out a formula using this experience curve to get the total exp after each level. I bet its easy and im just over thinking it.

maxlvl = 10;
increment = 28;
baseexp = 100;
function calc(){
    for (i = 0;i<(maxlvl*increment);i+=increment){
        expperlvl = baseexp + i;
        document.writeln(expperlvl);
    }
}
share|improve this question
1  
If you solved your problem, add an answer and accept it, don't edit your question. –  Byte56 Jun 10 '12 at 16:57

2 Answers 2

If you're just trying to calculate the experience at maxlvl (10), and you want it so that each level requires increment (28) more experience than the last, you can just use this formula (without the loop):

var expperlvl = baseexp + ((maxlvl - 1) * increment);
//Note: I subtract 1 from max level so that level 1 = baseexp.

However, this is linear and not a "curve" so you'll have to be more specific about what you are trying to do.

share|improve this answer
    
@Drackir -- I figured out the formula. I edited my post with the solution. Sorry i wasnt more clear, but I was trying to calculate the total exp at maxlvl. Is there any simplification able to be done? –  StealingMana Jun 10 '12 at 14:46
up vote 1 down vote accepted

I figured it out. I decided to attempt to work out the formula on paper first and success.

minlvl=1;
maxlvl=6;
base=200;
increment=56;
function total(){
    totalxp=(base*(maxlvl-minlvl))+(increment*(.5*(maxlvl-minlvl)*(maxlvl-minlvl-1)));
    document.write(totalxp);
}

(made alteration to the formula, now its correct)

share|improve this answer
3  
A better answer would include an explanation of what was wrong and how you fixed it, not just code. Thank you for posting this as an answer instead of editing your question though. Improving this answer may just net you some reputation and you can level up to more privileges. –  Byte56 Jun 11 '12 at 5:48

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.