php - Text Based Game - XP, Rank, Percent -
i'm pretty new programming, i've learned php , html. trying make text based "rpg" game. i've made few functions gambling, killing, , doing crimes (yes, it's mafia related game). i've made possible "level up" in game, , stunningly enough, made work perfectly, ran on small issue. want let players see progress, using "rank bar", it's same concept experience points, want show percent. of now, looks this:
$percent = $currentxp / $nextlevelxp; $percent2 = $percent * 100; $percent3 = number_format($percent2, 0);
this worked me (you can see xp, , level up), problem is, when level up, show percent next level using current xp, means might 50% when you've leveled up. there way can make 0% @ next rank, , make go 100% before level up? i'd prefer basic kind of code. thank in advance!
change first line to:
$percent = ($currentxp - $curlevelxp) / ($nextlevelxp - $curlevelxp);
this isn't programming problem, it's simple math.
Comments
Post a Comment