import pygame from pocket_friends.game_files.io.input_handler import InputHandler class Surface(pygame.Surface): def __init__(self, window_size, resources_dir, game_fps, **kwargs): super().__init__(window_size, pygame.SRCALPHA) self.name = 'error_screen' self.running = True self.next_surface = 'title' self.clock = pygame.time.Clock() self.input_handler = InputHandler(self.clock) self.additional_args = {} self.bg = pygame.image.load(resources_dir + '/images/bg.png').convert_alpha() self.title = pygame.image.load(resources_dir + '/images/debug/invalid.png').convert_alpha() self.frames = 1 self.game_fps = game_fps self.delay = 1 self.font = pygame.font.Font(resources_dir + '/fonts/5Pts5.ttf', 10) def update(self): self.clock.tick(self.game_fps) self.blit(self.bg, (0, 0)) self.blit(self.title, (0, -4)) text = self.font.render('Frames: {0}'.format(self.frames), False, (64, 64, 64)) self.blit(text, (3, 68)) self.frames += 1 self.frames %= self.game_fps self.input_handler.update() for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_b: self.running = False