0
請幫我,我已經開始在pygame最近寫的程序,我可以通過這個障礙,我無法找到任何幫助在線。所以更具體的我需要的是,當我按下tab鍵可能只是一次因爲如果我把KEYDOWN我不得不對我總是按下鍵我會離開開始的背景,然後會出現一條消息。感謝您的時間。當我按下一次按鍵時,如何讓代碼顯示新的背景?
import pygame
import random
perguntaa = random.randint(1,2)
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
BLUE = (0, 0, 255)
ORANGE = (255, 154, 23)
pygame.init()
size = (700, 500)
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Quem quer ser Milionário")
clock = pygame.time.Clock()
done = False
while not done:
for event in pygame.event.get():
screen.fill(ORANGE)
pygame.draw.rect(screen, BLACK, [225, 200, 250, 100])
font = pygame.font.SysFont('cambria', 100, False, False)
text = font.render("Play", True, WHITE)
screen.blit(text, [225, 200])
if event.type == pygame.QUIT:
done = True
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
screen.fill(ORANGE)
pygame.draw.rect(screen, BLACK, [0, 50, 700, 100])
pygame.display.flip()
clock.tick(30)
pygame.quit()