Trying to display a png file in pygame using pygame.display.update, and it shows for less than a second then disappears.

前端 未结 2 1101
情歌与酒
情歌与酒 2021-01-23 13:26

The image is a playing card. We are using pygame 4.5 community edition and pycharm 2.6.9 because 2.7 does not support pygame (this is a school). Here is the code:



        
2条回答
  •  广开言路
    2021-01-23 13:45

    Try this:

    import pygame
    pygame.init()
    picture=pygame.image.load("cards/S01.png")
    pygame.display.set_mode(picture.get_size())
    main_surface = pygame.display.get_surface()
    main_surface.blit(picture, (0,0))
    while True:
       main_surface.blit(picture, (0,0))
       pygame.display.update()
    

    pygame.display.update() updates a frame. There are multiple frames per second depending on what what you draw onto the surface.

提交回复
热议问题