php game, formula to calculate a level based on exp

前端 未结 7 2435
心在旅途
心在旅途 2020-12-23 10:34

Im making a browser based PHP game and in my database for the players it has a record of that players total EXP or experience.

What i need is a formula to translate

7条回答
  •  醉酒成梦
    2020-12-23 11:26

    Google gave me this:

    function experience($L) {
     $a=0;
      for($x=1; $x<$L; $x++) {
        $a += floor($x+300*pow(2, ($x/7)));
      }
     return floor($a/4);
    }
    
    for($L=1;$L<100;$L++) {
     echo 'Level '.$L.': '.experience($L).'
    '; }

    It is supposed the be the formula that RuneScape uses, you might me able to modify it to your needs. Example output:

    Level 1: 0
    Level 2: 55
    Level 3: 116
    Level 4: 184
    Level 5: 259
    Level 6: 343
    Level 7: 435
    Level 8: 536
    Level 9: 649
    Level 10: 773
    

提交回复
热议问题