【发布时间】:2020-06-12 02:11:33
【问题描述】:
如果一组条件为真,我想调用一个函数来检查它们是否为真。 如果函数确认它们是真的,我想通过在函数中设置 gameExit=True 来退出我的 pygame 游戏循环。
但是,即使条件已经满足,它也没有执行我的功能。
上下文:井字游戏,要退出游戏循环是所有顶部方块都有一个叉号。
def is_game_over(current_game,gameExit):
if current_game[0][0]=="cross" and current_game[0][1]=="cross" and current_game[0][2]=="cross":
gameDisplay.fill(white)
pygame.display.flip()
gameExit=True
while gameExit == False:
for event in pygame.event.get():
if event.type==pygame.QUIT:
gameExit=True
if event.type == pygame.MOUSEBUTTONDOWN:
placement = (place_clicked(pygame.mouse.get_pos(), "none")) # get the co-ordinates of place they clicked
*Below is a bunch of if statements, which call the function is_game_over if i want to exit the game loop"
【问题讨论】:
标签: python function loops pygame