import pygame


class Screen:

    def __init__(self, width=640, height=360, caption='Elironwars'):
        # Initialisation de Pygame
        pygame.init()

        # Création de la fenêtre
        self.width, self.height = width, height
        self.surface = pygame.display.set_mode((self.width, self.height))
        pygame.display.set_caption(caption)
        # Horloge pour limiter les FPS
        self.clock = pygame.time.Clock()

    @property
    def rect(self):
        return self.surface.get_rect()

    def refresh(self):
        # Met à jour l'affichage
        pygame.display.flip()

        # Limite à 60 FPS
        self.clock.tick(60)

    @staticmethod
    def close():
        pygame.quit()


if __name__ == '__main__':
    screen = Screen()

    loop = True
    while loop:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                loop = False

        screen.refresh()
