Создание Python 3 / Pygame Нажмите любую клавишу, чтобы продолжить стартовую страницу

Я знаю, что, вероятно, совершаю здесь очень простую ошибку, я изучаю 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()

»’

while pygame.mixer.music.get_busy(): будет продолжать зацикливаться, пока играет музыка, не так ли? Это означает, что вы застрянете в этом цикле, пока музыка не закончится   —  person Salamandrus    schedule 06.01.2020

Источник: ledsshop.ru

Стиль жизни - Здоровье!