What is a good way to draw images using pygame?

I would like to know how to draw images using pygame. I know how to download them. I made an empty window. When I use screen.blit (blank, (10,10)), it does not draw an image without leaving the screen blank.

+7
source share
3 answers

This is a typical layout:

myimage = pygame.image.load("myimage.bmp") imagerect = myimage.get_rect() while 1: your_code_here screen.fill(black) screen.blit(myimage, imagerect) pygame.display.flip() 
+11
source

After using blit or any other update on the drawing surface, you must call pygame.display.flip() to actually update the displayed one.

+2
source
 import pygame, sys, os from pygame.locals import * pygame.init() screen = pygame.display.set_mode((100, 100)) player = pygame.image.load(os.path.join("player.png")) player.convert() while true: screen.blit(player, (10, 10)) pygame.display.flip() pygame.quit() 

Loads the file "player.png" Run this and it works fine. So I hope you found out something.

+2
source

All Articles