class HorizontalBar: """Bar that has a length that depends on the value, eg. a health bar""" def __init__(self, image, length=100.0): self.image = Graphic(image) self.base_length = float(length) self.image.w = self.base_length self.image.setup_draw() self.max_value = None def set_value(self, value, max_value): value = float(value) max_value = float(max_value) self.image.w = value/max_value * self.base_length self.image.setup_draw() def set_max(self, max_value): self.max_value = float(max_value) def draw(self): self.image.draw()