Hi Im new to pygame and Coding in general And I just started a tutorial and Whenever I try and load my png images and I run the code i shows up as an error here is my code
import pygame
Whenever I try and do This It come up as an Error such as this
import pygame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
from pygame. locals import * pygame.init() screen_width = 800 screen_height = 600 screen = pygame.display.set_mode((screen_width,screen_height)) pygame.display.set_caption( 'Platformer' ) #load images bg_img = pygame.image.load( "img/sky.png" ) run = True while run: for event in pygame.event.get(): if event. type = = pygame.QUIT: run = False screen.blit(bg_img, ( 0 , 0 )) pygame.display.update() pygame.quit() |
Error:FileNotFoundError: No file 'img/sky.png' found in working directory 'C:\Users\yeg20\OneDrive\Desktop\workspace'.
Could anyone tell me why this is happening and how to fix it?
Larz60+ write Oct-12-2022, 02:19 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.
Also, when posting errors, paste the complete unaltered error traceback (error message) as it contains valuable debugging information.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.
Also, when posting errors, paste the complete unaltered error traceback (error message) as it contains valuable debugging information.