What I have might be a simpler version. I tried to add comments in the code to explain what I did.
ARL4EKNV
The math, which I didn't explain much in the program, stems from using the percentage of current HP to max HP and matching it to the length of the HP bar. The program gives you a kinda formula thing to work from so its easy to use.
I do mine real simple, with print characters. Basically this shows a full HP bar and whenever HP is reduced, call this function and it will LOCATE where the current HP bar stands and print blank spaces over the lost HP.
This is a real simple example and you can use math to have more HP in relation to LOCATE parameters so you don't get an error if you have like 100 HP