如何解决pygame 窗口中没有显示任何内容
我真的不知道如何处理这个没有显示在我的 pygame 窗口中,甚至没有显示在屏幕上。 fill()
行不执行任何操作。有人知道问题出在哪里吗?
import pygame
def game():
pygame.init()
black = (0,0)
green = (0,255,0)
running = True
screen = pygame.display.set_mode((800,600))
screen.fill(green)
button_rectangle = pygame.draw.rect(screen,black,(200,150,100,50))
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
game()
解决方法
您必须在事件循环中更新屏幕。
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# Update the screen.
pygame.display.update()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。