0

I already know I am going to get verbally abused because I know it is probably a simple fix. I am new to Python and I am trying to create a simple maze game for my class project. I am going over the tutorials which are quite simple, but when it attempted to import my logo, I keep getting the error that pygame couldn't open the image. Here is the code i've got thus far (after a couple of hours of googling, even found some on stack overflow but nothing seems to work):

import pygame
import os

def main():
    pygame.init()

    DIR = os.path.dirname(os.path.realpath("Python Stuff"))
    IMGS_DIR = os.path.join(DIR, "maze")

    logo = pygame.image.load(IMGS_DIR)
    pygame.display.set_icon(logo)
    pygame.display.set_caption("minimal program")


    screen = pygame.display.set_mode((240,180))


    running = True
    while running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False


if __name__ == "__main__":
    main()

for the love of science, I have no idea what I am doing incorrectly. I have tried three different codes. The current os code i have implemented is supposed to be the direct path, but I am still getting the "Could not open ..../maze" error. The files are in the right spot, no spelling errors, the image is a PNG file, I have no idea what's going on. PLS HELP. I should be able to complete most, if not all, of the project today, as the character implementation is going to be the most difficult for this simple project.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • 1
    Try using "maze.png" – Seppeke Apr 11 '21 at 14:39
  • 2
    [`pygame.image.load()`](https://www.pygame.org/docs/ref/image.html) loads one single image. You must specify the filename of the image. – Rabbid76 Apr 11 '21 at 14:41
  • 1
    Thank you guys. I knew it was simple fix. I am so excited right now!! I wish I could buy you guys a coffee or something. The maze.png worked fine. I'll take notes of the functions and reasons why they don't work so I'll know next time. – Chef Sweaty Apr 11 '21 at 14:45

0 Answers0