Develop an experience bar

0

I am developing a minigame in Processing and I am in a dilemma, I have a functional exp bar to some extent, when the bar reaches the max of experience it resets to 0 (which is fine) but the issue is that for example I have this case:

-exp current: 1000
-exp to next level: 10
and I kill a npc that gives me 1000 of exp

The idea is to add that difference to the next level and (in case it happens) raise more levels with that difference, let's say you pass to level 3 of one.

If anyone has any ideas, read them!

Thank you very much! if part of the code is needed, let me know

    
asked by Munstar 08.12.2018 в 23:27
source

2 answers

0

I think this was what you wanted to ask, would not you?

- function getExpTotLvl(Lvl){}
- function getExpSigLvl(ExpActual){return Exptot - expSigLvl}
- function +Exp(Exp, ExpSigLvl){
if(Exp > ExpSigLvl){
return Lvl++
return ExpSobrante}
else{return Lvl++}
}
    
answered by 09.12.2018 в 00:27
0

In the end I got another method, I used variables to assign the xp of the npc (currently they are 2) and I did an if with this algorithm:

              if (xpActual + xpCruceros > xpNivel){

            xpActual = (xpActual - xpNivel) + xpCruceros;
            lvlUp = true;
            nivel++;
          }
            else {

              xpActual +=xpCruceros;

            }

Thanks for your answers !!

    
answered by 09.12.2018 в 21:32