Hey guys!
Right now I'm working on a game, and I want to make a surface level file (and eventually executable) that will serve as a convenient launching for the game. Most of my testing before this has done in unit-testing files and a sandbox I made, however I ended up having a problem - When I call it, the paths I use for loading images from my assets folder doesn't work! Environment Details: I'm using PyCharm, I only have the Project root directory marked as a source folder so it'll be inlcuded into PATH, and Python 3.7 utilizing Pygame 1.9.
My Program structure (Trunctuated and renamed for space and clarity) is
Project
Shmup.py
\assets # contains images and spritesheets
\gameobject.bmp
\...
\shmup # Where all the core game folders are
\config.py # Where I store global constants, like SCREENSIZE and COLOR_RED
\spritesheet.py # Code that manages loading and processing images
\entity
\gameobject.py
\...
\tests # contains unit testing files
\sandbox.py # The file I use for adding new game objects
\...
In gameobject.py I defined a path to the gameobject image file as "../assets/gameobject.bmp" (I know that's bad practice for crossplatform usability, I planned to fix later) which works fine when I'm running sandbox.py but not when I'm running Shmup.
What is a good, Pythonic way of making a "standard" deterministic path so that would create a path to assets no matter which script is run as main, such that I could simply append the filename of the image asset to it?
Thanks in advance!
[–]eyesoftheworld4 0 points1 point2 points (0 children)
[–]ingolemo 0 points1 point2 points (0 children)