这是我程序的一部分
running = True
win_size = [800,600]
Color_screen=[201, 169, 167]
Color_line=(0,0,0)
# initialize pygame
pygame.init()
scr = pygame.display.set_mode(win_size)
pygame.display.set_caption('Traverse')
scr.fill(Color_screen)
pygame.display.flip()
# Drawing Traverse
for i in range(len(x)-1):
pygame.time.delay(1000)
pygame.draw.line(scr,Color_line,(x[i],y[i]),(x[i+1],y[i+1]))
pygame.display.flip()
# Displaying Scale
font = pygame.font.Font('freesansbold.ttf', 32)
text = font.render(f'Scale : {scale} pixels = 1 metre', True, Color_line)
textRect = text.get_rect()
textRect.center = (100, 50)
scr.blit(text,[100,20])
while running:
# looking for events
for events in pygame.event.get():
if events.type == QUIT:
running = False
pygame.quit()
一切似乎都可以正常工作,只是文本没有显示在屏幕上。 正在绘制导线,但未绘制文字。 代码中缺少什么吗?