0

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

/glider
/libs
classes.py
/graphics
/rooms
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!

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by fallopiano
0

Have a look at:
http://docs.python.org/library/os.path.html

You probably need some of the following:
os.getcwd()
os.path.join()
os.path.listdir()
os.path.isdir()
os.path.isfile()

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 \

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.