def start_menu(): global closed if closed: return # функция для создания, отрисовки стартового меню screen = StartMenu() game = True res = -1 # переменная, возвращающая состояние экрана while not transition.get_transition(): # отображение перехода между меню for event in pygame.event.get(): if event.type == pygame.QUIT: closed = True return transition.render() pygame.display.flip() clock.tick(fps) screen.render() while game: for event in pygame.event.get(): if event.type == pygame.QUIT: game = False closed = True if event.type == pygame.KEYDOWN: keys = pygame.key.get_pressed() if keys[pygame.K_SPACE] or keys[ pygame.K_RETURN]: # переход в меню выбора карт screen.result = 1 pygame.mixer.music.stop() if transition.get_transition(): # отображение перехода между меню if not transition.background: # сохранение изображения на экране для быстрой отрисовки pygame.image.save(display, 'image/background_for_load.png') transition.background = load_image('background_for_load.png') transition.render() else: screen.render() pygame.display.flip() clock.tick(fps) res = screen.get_result() if res != -1: game = False if res == 1: frame = transition.get_frame() # смена состояния перехода if frame != 35 and frame != -1: transition.reverse() transition.background = None select_map()
def start_menu(): screen = StartMenu() game = True while game: for event in pygame.event.get(): if event.type == pygame.QUIT: game = False screen.draw() pygame.display.flip() clock.tick(30) res = screen.get_result() if res != -1: game = False if res == 1: select_chr()