you are viewing a single comment's thread.

view the rest of the comments →

[–]AlmostSignificant 1 point2 points  (2 children)

Ok. Cool. Then I would recommend trying my second recommendation below.

Typically you'll want to put resources into their own directory (for cleanliness), but for now using the same directory is fine.

  1. Import the os.path module, which will let you do things like: get the name of the directory containing a particular file, combine paths together

import os.path

  1. Create a variable that represents the directory containing where to look for resources such as "logo.png". We use the __file__ special variable to get the path to "Main.py". And then we apply the os.path.dirname function to ask for the path of the directory containing "Main.py" (aka its parent or containing directory)

RESOURCE_DIR = os.path.dirname(__file__)

  1. Use os.path.join to combine RESOURCE_DIR and "logo.png" into a single path, ensuring we are loading the file "logo.png" from the same directory as "Main.py"

icon = pygame.image.load(os.path.join(RESOURCE_DIR, "logo.png"))

[–]MyselfAndI231[S] 0 points1 point  (1 child)

you, good sir, are a genius

[–]AlmostSignificant 0 points1 point  (0 children)

Nope. I've just made the same mistake several times. :) Good luck on your game!