【发布时间】:2019-06-05 02:31:00
【问题描述】:
我可以在我的显示器上显示一个数字“1”。现在,我的目标是显示数字 1...4。即先显示“1”,再显示1后显示“2”,以此类推。如何解决?
这是我的代码:
import pygame
import time
pygame.init()
screen = pygame.display.set_mode((640, 480))
clock = pygame.time.Clock()
done = False
font = pygame.font.SysFont("comicsansms", 72)
text = font.render("1", True, (0, 128, 0))
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
done = True
screen.fill((255, 255, 255))
screen.blit(text,
(320 - text.get_width() // 2, 240 - text.get_height() // 2))
pygame.display.flip()
clock.tick(60)
【问题讨论】: