import pygame from game_object import GameObject from snake import Snake class GameOverScreen(GameObject): def __init__(self, window_size, color): font = pygame.font.SysFont('Arial', 140) self.__text_surface = font.render('GAME OVER', True, color) self.__pos = [0.5*(win_size - font_size) for win_size, font_size in zip(window_size, self.__text_surface.get_size())] self.__is_visible = False def draw(self, surface): if self.__is_visible: surface.blit(self.__text_surface, self.__pos) def update(self, user_input, game_objs): for obj in game_objs: if isinstance(obj, Snake) and obj.is_dead(): self.__is_visible = True