What is a good way to draw images using pygame?

前端 未结 4 853
灰色年华
灰色年华 2020-12-06 05:49

I would like to know how to draw images using pygame. I know how to load them. I have made a blank window. When I use screen.blit(blank, (10,10)), it does not d

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-06 06:34

    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 perfectly. So hopefully you learn something.

提交回复
热议问题