Привет. Я пытаюсь отобразить menu_background на экране меню, где отображаются пункты меню. Когда я запускаю свой код, все, что я получаю, это прокрутка изображения, но мои пункты меню и звук не воспроизводятся и не отображаются. Кто-нибудь может помочь написать код, который заставит его работать там, где воспроизводится звук и отображаются параметры моего меню?
import pygame, sys, random, time, os, math
from pygame.locals import *
fps = pygame.time.Clock()
global screen
screen = pygame.display.set_mode((WIDTH, HEIGHT),pygame.FULLSCREEN)
display = pygame.Surface((400,250))
def menu_background():
menu_bg = pygame.image.load("assets/images/menu_bg.png").convert()
x = 0
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
rel_x = x % menu_bg.get_rect().width
screen.blit(menu_bg, (rel_x - menu_bg.get_rect().width, 0))
if rel_x < WIDTH:
screen.blit(menu_bg, (rel_x, 0))
x -= 1
pygame.display.update()
fps.tick(120)
def menu():
bg = menu_background()
menu_options = ['Play','Controls','Highscores','Settings','Credits','Quit']
menu_choice = 0
in_menu = True
pygame.mixer.music.load('assets/audio/mainmenu.wav')
while in_menu:
bg(display)
n = 0
for option in menu_options:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
pygame.quit()
sys.exit()
if event.key == K_UP:
menu_choice -= 1
if menu_choice < 0:
menu_choice = len(menu_options)-1
if event.key == K_DOWN:
menu_choice += 1
if menu_choice >= len(menu_options):
menu_choice = 0
if event.key == K_SPACE:
choice = menu_options[menu_choice]
if choice == 'Play':
play()
if choice == 'Controls':
controls()
screen.blit(pygame.transform.scale(display,(WIDTH,HEIGHT)),(0,0))
pygame.display.update()
fps.tick(60)