0

I am currently working on a little simple game for a class and because I am supposed to then give it to my teacher who will be looking at it on his own computer, I can't use paths like pygame.image.load('C:/Users/name/Desktop/project/mapwitheverything.png') But when I don't, even if my python file and my image are in the same file, VSC always shows me "FileNotFoundError: No file 'mapwitheverything.png' found in working directory 'C:\Users\name'"

Here is my current code:

class ysortcameragroup(pygame.sprite.Group):
def __init__(self):

    super().__init__()
    self.display_surface = pygame.display.get_surface()
    self.half_width = self.display_surface.get_size()[0] // 2
    self.half_height = self.display_surface.get_size()[1] // 2
    self.offset = pygame.math.Vector2()

    self.floor_surf = pygame.image.load('mapwitheverything.png').convert_alpha()
    self.floor_rect = self.floor_surf.get_rect(topleft = (0,0))
Nora
  • 1
  • 1
    See [Could not open resource file, pygame error: "FileNotFoundError: No such file or directory."](https://stackoverflow.com/questions/58177145/could-not-open-resource-file-pygame-error-filenotfounderror-no-such-file-or) and add the following at the very begin of your code: `import os` `os.chdir(os.path.dirname(os.path.abspath(__file__)))` – Rabbid76 Oct 01 '22 at 14:05

0 Answers0