我想在Python中画一条线,但是当我运行下面的代码时,这条线永远不会出现。实际上,我需要创建一个4x4节的字段,但是让我们从一行开始。 我的代码:
import sys, pygame
from pygame.locals import*
width=1000
height=500
Color_screen=(49,150,100)
Color_line=(255,0,0)
def main():
screen=pygame.display.set_mode((width,height))
screen.fill(Color_screen)
pygame.display.flip()
pygame.draw.line(screen,Color_line,(60,80),(130,100))
while True:
for events in pygame.event.get():
if events.type == QUIT:
sys.exit(0)
main()
怎么了?
画线后,必须用
pygame.display.flip
更新计算机的显示。通常在每帧while循环的底部执行一次。
在画线后执行pygame.display.flip()操作:
问题是你在排队的人出现之前就把他们给遮住了。 请改为:
相关问题 更多 >
编程相关推荐