Skip to content Skip to sidebar Skip to footer

Pygame Not Finding Image Folder When In Subdirectory

I've been refactoring my game so that some files are placed in a subdirectory called /lib/ [File Structure below]. Two of these files are a python file called media.py, and a fold

Solution 1:

your code depends on the start directory.

To be independent from that you could use the fact that the image file is in the same directory as Media.py and the dir name of __file__ object

Then:

blue = pygame.image.load(os.path.join(os.path.dirname(__file__), 'Media','blue.png')).convert_alpha()

will do the trick

Post a Comment for "Pygame Not Finding Image Folder When In Subdirectory"