Ask coding questions

← Back to all posts
Ok so Blitting
LukeShomper (5)

I know how to blit I would do somthing like this
image = pygame.image.load('image.png')
imagerect = image.get_rect()
Screen.blit(image, imagerect)
and then you would update the screen
but what if the file was in a folder? what would I do if it was in the folder?
would I do the directory or how would i do somthing like this
image = pygame.image.load('folder\image.png') ?

Answered by LeonDoesCode (272) [earned 5 cycles]
View Answer
Commentshotnewtop
LeonDoesCode (272)

If the file is in a folder, then you would write it like normal. E.g

image = pygame.image.load('folder/image.png')

You would just add a / for every director leading to the file. So if it was in a sub-directory of a directory, you would just have to add subdirectory/ to the current one. E.g

image = pygame.image.load('folder/subdirectory/image.png')
LukeShomper (5)

also nothing is wrong with the code