hi everyone. Say I have my project directorys set up like so:

room images go here

I'm trying to access a image from graphics/rooms, but from classes.py. I'm using pygame, and I know to go back a folder in a dir; you use:

#  go back a folder and load an image
pygame.image.load( '..\image.bmp' )

but how would I go from classes.py to graphics/rooms/room.bmp? I thought of using:

pygame.image.load( '..\graphics/rooms/room.bmp' )

you think you could use that, but it doesn't work... anyone know what could be the problem? any comments or help would be great. Thanks!

Recommended Answers

All 2 Replies

Have a look at:

You probably need some of the following:

Try to use these functions and not the literal path. This way, your program will be cross-platform and you will avoid such errors about / and \

thanks, but I forgot to mention something. There is a file called main.py that is in the glider folder. main.py calls classes.py. So is my program trying to access the image files from classes.py or main.py?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.