Pygame Add Image to Surface

So, you know how to make a simply pygame window, and now you want to do something a bit more interesting, aye?

download-bttn
Download Code

How do you  add an image to your pygame surface ?

In this quick tutorial, we’ll show you exactly that. So that your finished product will look like is the following picture :

 

pygame-image-on-surface

 

Here’s the full Python code:

So, remember that the top left corner is where the coordinates will place the image so x = 20,y = 30  in lines 13/14 means that that’s where the top left corner of the image is.

pygame display image

Now, this only works if the image is in the *same folder* as your script.peng-east

 

Here’s what the folder  structure should look like (It’s important that the image “peng-east.png” is in the same folder as the “display-pygame-image.py” file.

folder-structure