diff --git a/src/hud.py b/src/hud.py index 09e9d74..eba708c 100644 --- a/src/hud.py +++ b/src/hud.py @@ -21,3 +21,27 @@ def _format_time(total_seconds): mins = total_seconds // 60 secs = total_seconds % 60 return f"TIME {mins:02}:{secs:02}" + + +class HUD: + def __init__(self): + self.font = pygame.font.SysFont(HUD_FONT, HUD_FONT_SIZE, bold=HUD_FONT_BOLD) + + def draw(self, screen, door, zombie, ects, total_time): + # --- DOOR HP --- + _draw_status_bar(screen, HUD_BAR_X, HUD_Y_DOOR, door.current_hp, COLOR_HP_BAR_GREEN) + # -5 px, small off-set to align the text better with hp bar + screen.blit(self.font.render("DOOR HP ", True, COLOR_HUD_TEXT), (HUD_X_OFFSET, HUD_Y_DOOR - 5)) + + # --- ZOMBIE HP --- + if zombie: + _draw_status_bar(screen, HUD_BAR_X, HUD_Y_ZOMBIE, zombie.current_hp, zombie.max_hp, COLOR_HP_BAR_RED) + screen.blit(self.font.render("Zombie HP:", True, COLOR_HUD_TEXT), (HUD_X_OFFSET, HUD_Y_ZOMBIE - 5)) + + # --- ECTS --- + ects_info = f"ECTS: {ects.ects_balance} ({ects.ects_per_second}/s)" + screen.blit(self.font.render(ects_info, True, COLOR_HUD_TEXT), (HUD_X_OFFSET, HUD_Y_ECTS)) + + # --- TIME --- + time_str = _format_time(total_time) + screen.blit(self.font.render(time_str, True, COLOR_HUD_TEXT), (screen.get_width() - 150, HUD_Y_DOOR - 5)) \ No newline at end of file