我为我的游戏创建了一个菜单,但该菜单无法打开。我尝试了不同的方法,发现此方法将最有效。但是游戏已经在第一级上打开了,老实说我不知道该怎么办了。我确实写了所有颜色,使用了字体并设置了显示,但仍然无法正常工作。
def main_menu():
menu = True
selected = "start"
while menu:
for event in pg.event.get():
if event.type == pg.QUIT:
pg.quit()
quit()
if event.type == pg.KEYDOWN:
if event.key == pg.K_UP:
selected = "start"
elif event.key == pg.K_DOWN:
selected = "quit"
if event.key == pg.K_RETURN:
if selected == "start":
print("Start")
if selected == "quit":
pg.quit()
quit()
screen.fill(blue)
title = text_format("White Collar: The Game", font, 90, yellow)
if selected == "start":
text_start = text_format("START", font, 75, white)
else:
text_start = text_format("START", font, 75, black)
if selected == "quit":
text_quit = text_format("QUIT", font, 75, white)
else:
text_quit = text_format("QUIT", font, 75, black)
我期望使用游戏菜单,但出现此错误:
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 33,
in _python_exit
def _python_exit(): File "/snap/pycharm-
professional/154/helpers/pydev/_pydevd_bundle
/pydevd_trace_dispatch_regular.py", line 366, in __call__
def __call__(self, frame, event, arg):
KeyboardInterrupt