import pygame from actors.enums import Colors, PlayerDirection from actors.pacman import ActorPacman from labyrinth import Labyrinth __version__ = "0.2.0" def main() -> None: pygame.init() screen_width, screen_height = 800, 800 screen = pygame.display.set_mode((screen_width, screen_height)) pygame.display.set_caption("Pac-Man " + __version__) labyrinth = Labyrinth(screen, width=screen_width, height=screen_height) player = ActorPacman(screen, center=(200, 200)) clock = pygame.time.Clock() running = True while running: screen.fill(Colors.Black) for event in pygame.event.get(): match event.type: case pygame.QUIT: running = False case pygame.KEYDOWN: match event.key: case pygame.K_RIGHT: player.direction = PlayerDirection.DirectionRight case pygame.K_LEFT: player.direction = PlayerDirection.DirectionLeft case pygame.K_UP: player.direction = PlayerDirection.DirectionUp case pygame.K_DOWN: player.direction = PlayerDirection.DirectionDown case pygame.JOYHATMOTION: hat_x, hat_y =event.value if hat_x == 1: player.direction = PlayerDirection.DirectionRight elif hat_x == -1: player.direction = PlayerDirection.DirectionLeft elif hat_y == 1: player.direction = PlayerDirection.DirectionUp elif hat_y == -1: player.direction = PlayerDirection.DirectionDown labyrinth.draw() player.animate() player.draw() pygame.display.flip() clock.tick(60) pygame.quit() if __name__ == "__main__": main()