【问题标题】:Pygame fill command not working?Pygame填充命令不起作用?
【发布时间】:2020-06-06 22:16:54
【问题描述】:

我对 python 很陌生,我开始掌握它的窍门,现在我开始使用 pygame,我试图用颜色填充屏幕,但由于某种原因它不起作用这是我的代码

import pygame
pygame.init()

white = (255,255,255)
black = (0,0,0)
orange = (255,165,0)

display = pygame.display.set_mode((1280,1024))

pygame.display.set_caption('ReflectOS')

Exit = False

while not Exit:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            Exit = true

            display.fill(white)
            pygame.display.update()

        print(event)

pygame.quit()
quit()

【问题讨论】:

    标签: python python-3.x pygame


    【解决方案1】:

    你有错误的缩进 - 你只有在退出程序时才填满屏幕

    import pygame
    
    white = (255,255,255)
    black = (0,0,0)
    orange = (255,165,0)
    
    
    pygame.init()
    display = pygame.display.set_mode((1280,1024))
    pygame.display.set_caption('ReflectOS')
    
    exit = False
    
    while not exit:
    
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                exit = True
            print(event)
    
        display.fill(white)
        pygame.display.update()
    
    pygame.quit()
    quit()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-19
      • 2012-08-02
      • 2014-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-01
      • 1970-01-01
      相关资源
      最近更新 更多