import pygame


class UI:
    def __init__(self, surface):

        # setup
        self.display_surface = surface

        # health
        self.health_border = pygame.image.load(
            'graphics/ui/Border_0.png').convert_alpha()
        self.health_bar = pygame.image.load(
            'graphics/ui/Health_0.png').convert_alpha()
        self.health_bar_topleft = (50, 41)
        self.bar_max_width = 152
        self.bar_height = 3
        # coins
        self.coin = pygame.image.load('graphics/ui/coin.png').convert_alpha()
        self.coin_rect = self.coin.get_rect(topleft=(50, 61))
        self.font = pygame.font.Font(None, 30)

    def show_health(self, current, full):

        self.display_surface.blit(self.health_bar, (25, 10))
        self.display_surface.blit(self.health_border, (25, 10))
        current_health_ratio = current / full
        current_bar_width = self.bar_max_width * current_health_ratio
        health_bar_rect = pygame.Rect(
            (self.health_bar_topleft), (current_bar_width, self.bar_height))
        pygame.draw.rect(self.display_surface,  '#dc4949', health_bar_rect)

    def show_coins(self, amount):
        self.display_surface.blit(self.coin, self.coin_rect)
        coin_amount_surf = self.font.render(str(amount), False, 'black')
        coint_amount_rect = coin_amount_surf.get_rect(
            midleft=(self.coin_rect.right + 4, self.coin_rect.centery))
        self.display_surface.blit(coin_amount_surf, coint_amount_rect)

import pygame


class UI:
    def __init__(self, surface):

        # setup
        self.display_surface = surface

        # health
        self.health_border = pygame.image.load(
            'graphics/ui/Border_0.png').convert_alpha()
        self.health_bar = pygame.image.load(
            'graphics/ui/Health_0.png').convert_alpha()
        self.health_bar_topleft = (50, 41)
        self.bar_max_width = 152
        self.bar_height = 3
        # coins
        self.coin = pygame.image.load('graphics/ui/coin.png').convert_alpha()
        self.coin_rect = self.coin.get_rect(topleft=(50, 61))
        self.font = pygame.font.Font(None, 30)

    def show_health(self, current, full):

        self.display_surface.blit(self.health_bar, (25, 10))
        self.display_surface.blit(self.health_border, (25, 10))
        current_health_ratio = current / full
        current_bar_width = self.bar_max_width * current_health_ratio
        health_bar_rect = pygame.Rect(
            (self.health_bar_topleft), (current_bar_width, self.bar_height))
        pygame.draw.rect(self.display_surface,  '#dc4949', health_bar_rect)

    def show_coins(self, amount):
        self.display_surface.blit(self.coin, self.coin_rect)
        coin_amount_surf = self.font.render(str(amount), False, 'black')
        coint_amount_rect = coin_amount_surf.get_rect(
            midleft=(self.coin_rect.right + 4, self.coin_rect.centery))
        self.display_surface.blit(coin_amount_surf, coint_amount_rect)

# setup # health # coins