0
我正在做一個骰子滾動程序,當骰子滾動時,它顯示它的隨機面,然後是最後的面。但問題是當骰子滾動時它只顯示第一張臉並且不會更新到其他臉部。有人知道爲什麼會發生這種情況?pygame窗口不會更新圖像
下面的代碼:
from pygame.locals import *
from random import randint
import pygame
import sys
for x in range(11):
if x > 1:
n = randint(1,6)
print(x,":",n)
pygame.init()
screen = pygame.display.set_mode((500,500),0,32)
one = pygame.image.load("one.png").convert_alpha()
two = pygame.image.load("two.png").convert_alpha()
three = pygame.image.load("three.png").convert_alpha()
four = pygame.image.load("four.png").convert_alpha()
five = pygame.image.load("five.png").convert_alpha()
six = pygame.image.load("six.png").convert_alpha()
while True:
for evt in pygame.event.get():
if evt.type == pygame.QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
if n == 1:
screen.blit(one,(250,250))
if n == 2:
screen.blit(two,(250,250))
if n == 3:
screen.blit(three,(250,250))
if n == 4:
screen.blit(four,(250,250))
if n == 5:
screen.blit(five,(250,250))
if n == 6:
screen.blit(six,(250,250))