Sometimes, we want to draw images using Python pygame.
In this article, we’ll look at how to draw images using Python pygame.
How to draw images using Python pygame?
To draw images using Python pygame, we can use the blit
method.
For instance, we write
my_image = pygame.image.load("image.bmp")
image_rect = myimage.get_rect()
while true:
#...
screen.fill(black)
screen.blit(my_image , image_rect)
pygame.display.flip()
to load the image.bmp image with
myimage = pygame.image.load("myimage.bmp")
The in an infinite while loop, we call screen.blit
with the my_image
image and the image_rect
to draw the image.
Conclusion
To draw images using Python pygame, we can use the blit
method.