New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Bar
I want to make a bar that can increase or decrease depending on a variable (that has a max that can be increased). the bar won't be shown all the time or increased over time (like a loading bar). what's the best way to do it? basically like a health bar. EDIT: this is for python shell
4 Answers
+ 3
I wrote this for you:
https://code.sololearn.com/c8gS0Mug0O0Y/?ref=app
+ 2
I'm starting to go a bit overboard with mine :D finished maxhp buff, potion and damage/armor additions :D I think I'll add the hp thing i made .D
max_hp = 100
current_hp = 60
def healthbar(max_hp, current_hp, *args):
base = "[||||||||||]"
calc = int(((max_hp - current_hp) / 10))
if calc != 0:
print(base[0:-calc], end="")
print(" "*(len(base)-len(base[0:-calc])), end="")
print("]")
else:
print(base)
print(current_hp)
healthbar(max_hp, current_hp)
0
made my own version of the code
https://code.sololearn.com/c8cN2vinVYFs/?ref=app
0
Markus Kaleton Great to see an alternative solution ☺