I have three variables to account for I'm having problem getting bar to always be the right size depending on the current exp value
the bar itself is 170 pixel wide / initial value set to 0
variable 1 bar.initialWidth = 0
exp = 0
then 5 global values
lvl1 = 240
lvl2 - 480
I'm trying to have that bar grow with his exp and max out filling the bar to 170 pixels when the lvl1 exp needed is reached and lvl2 exp is reached ext...
i have tried something I used on an old game for health
(Self.InitialWidth + (Math_Boy.exp-Math_Boy.MaxExp)*(Self.InitialWidth/Math_Boy.maxExp))
but that didn't work granted I changed the way the MaxExp was working but even setting the player to hold both the MaxExp and the exp value didn't work in this case... can't figure out why?
You should use Array, to contain data of levels scope.
Then, you need variable, to get data from array (CurrentLevel)
Formula of changing bar's (healthbar, manabar, expbar...) size is very simple:
Width of your bar / Value you want to reach * Current Value
Then, if value of your CurrentExp is greater or equal to scope, you need to make a little check:
x1 = 240
x2 = 580
CurrentLevel = 1 (So the scope is 240)
CurrentExp = 260
You will get level 2 and 20 exp with it
I hope I have explained completely enough
Develop games in your browser. Powerful, performant & highly capable.
wow thank you soo much that was very insightful
oh i was too slow, anyway here is another solution with the dictionary