import pygame
from funcoes import *

class GameOver:
    def __init__(self):
        pygame.init()
        self.window = pygame.display.set_mode((720, 480))
        pygame.display.set_caption('Pokémon')

        self.assets = {
            'pikachu' : pygame.transform.scale(pygame.image.load('assets/pikachu_fainted.png'), (321, 168)),
            "fonte":  pygame.font.Font("assets/Univers Next Pro Heavy Condensed.ttf", 50),
            "fonte_pequena":  pygame.font.Font("assets/Univers Next Pro Heavy Condensed.ttf", 30),
        }
    
    def desenha(self):
        self.window.fill((0, 0, 0))
        txt = pygame.font.Font.render(self.assets['fonte'], "GAME OVER", True, (255, 0, 0))
        self.window.blit(txt, (self.window.get_width()//2 - txt.get_width()//2, self.window.get_height()//3 - txt.get_height()//2 - 100))
        self.window.blit(self.assets['pikachu'], (self.window.get_width()//2 - self.assets['pikachu'].get_width()//2, self.window.get_height()//2 - self.assets['pikachu'].get_height()//2))

        txt = pygame.font.Font.render(self.assets['fonte_pequena'], "(R) Reiniciar", True, (255, 255, 255))
        self.window.blit(txt, (self.window.get_width()//3 - txt.get_width()//2, 370))
        txt = pygame.font.Font.render(self.assets['fonte_pequena'], "(Esc) Sair", True, (255, 255, 255))
        self.window.blit(txt, (self.window.get_width() - self.window.get_width()//3 - txt.get_width()//2, 370))

        pygame.display.update()
        
    def update(self):
        for evento in pygame.event.get():
            if evento.type == pygame.QUIT:
                return 'sair'
            if evento.type == pygame.KEYDOWN and evento.key == pygame.K_ESCAPE:
                fadeout(self.window)
                return 'sair'
            if evento.type == pygame.KEYDOWN and evento.key == pygame.K_r:
                fadeout(self.window)
                return 'reinicia'