Я знаю, что, возможно, я делаю очень основную c ошибку здесь, я изучал python около недели и меняюсь, и я пытаюсь создать стартовый экран для текстовой приключенческой игры, которая позволяет Пользователь может нажать любую клавишу, чтобы перейти к следующему экрану, который выражается в виде функции, но он не работает, несмотря на попытки перестановок.
'' '
import time
import pygame
import os
from pygame.locals import
pygame.init()
pygame.display.init()
pygame.mixer.init()
os.environ['SDL_VIDEO_CENTERED'] = '1'
pygame.display.set_caption("GK-Sierra\'s Text Adventure - Comic by Tom Siddell")
screen = pygame.display.set_mode((1800, 1000))
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
BLUE = (0, 0, 255)
BLACK = (0, 0, 0)
FUCHSIA = (255, 0, 255)
GRAY = (128, 128, 128)
LIME = (0, 128, 0)
MAROON = (128, 0, 0)
NAVYBLUE = (0, 0, 128)
OLIVE = (128, 128, 0)
PURPLE = (128, 0, 128)
TEAL = (0, 128, 128)
def title_screen():
title_screen_display = True
while title_screen_display:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
quit()
elif event.type == pygame.KEYDOWN:
title_screen_display = False
font = pygame.font.Font('spiritmedium.ttf', 40)
logo_image = pygame.image.load('logo.jpg')
title_screen_image = pygame.image.load('tictoc.jpg')
title_screen_image2 = pygame.image.load('firehand.jpg')
title_screen_soundtrack = 'bythewall.mp3'
screen.fill(BLACK)
screen.blit(title_screen_image, (520, 100))
screen.blit(title_screen_image2, (0, 600))
screen.blit(logo_image, (600, 0))
text = font.render('Press Any Key To Continue', True, PURPLE, BLACK)
textrect = text.get_rect()
textrect.center = (900, 950)
screen.blit(text, textrect)
pygame.display.update()
pygame.mixer.music.load(title_screen_soundtrack)
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
pygame.time.Clock().tick(10)
def input_screen():
input_screen_display = True
input = ""
font = pygame.font.Font('spiritmedium.ttf', 50)
while input_screen_display:
for evt in pygame.event.get():
if evt.type == KEYDOWN:
if evt.unicode.isalpha():
input += evt.unicode
elif evt.key == K_SPACE:
input = input + " "
elif evt.key == K_BACKSPACE:
input = input[:-1]
elif evt.key == K_RETURN:
input = ""
elif evt.type == QUIT:
return
screen.fill((0, 0, 0))
block = font.render(input, True, PURPLE)
rect = block.get_rect()
rect.center = screen.get_rect().center
screen.blit(block, rect)
pygame.display.flip()
if __name__ == "__main__":
name()
pygame.quit()
time.sleep(7)
quit()
title_screen()
input_screen()
' ''