hi I am learning pygame please.I am using windows computer.Please I want to upload images from opengameart.org.
I have downloaded them for my game.Please see the error that comes in my pygame.Please help me with this.
Many thanks
I’d try checking your img_dir
variable. Kinda seems like it might be pointing to the image file ship1.jpg
rather than the folder project1
.
The path it’s trying to open refers to the JPG twice: ...\Documents\project1\ship1.jpg\ship1.jpg
It looks like you’re repeating project1
as part of your path.
Perhaps you just want img_dir = path.dirname(__file__)
instead. What does your directory structure look like?
hi, when i write the code as you have said…after running the code it says invalid syntax.please see as attached.
You’re missing a parenthesis, but you no longer need the path.join. Just write it as
img_dir = path.dirname(__file__)
That is, assuming your images do actually live one directory up from where your file is – I don’t know what your directory structure looks like.