How do I prevent the player from moving through the walls in a maze?
Use mask collision. Draw the maze of a transparent pygame.Surface: cell_size = 40 maze = Maze() maze_surf = pygame.Surface((maze.size[0]*cell_size, maze.size[1]*cell_size), pygame.SRCALPHA) draw_maze(maze_surf, maze, 0, 0, cell_size, (196, 196, 196), 3) Crate a pygame.Mask from the Surface with pygame.mask.from_surface: maze_mask = pygame.mask.from_surface(maze_surf) Create a mask form the player: player_rect = pygame.Rect(190, 190, 20, 20) player_surf = … Read more