1 回答
TA贡献1780条经验 获得超3个赞
这是一个可以帮助您的框架。与上面的评论相同。您需要一个布尔变量来跟踪何时显示结束屏幕(发生了不好的事情),然后使用它来决定在主循环中绘制哪个屏幕......
def redrawwindow():
# basically what you have now...
def draw_end_screen():
# make this new function such that it shows your end-screen
run=True
end_condition=False # a new boolean variable to keep track if collision (or something else happened)
while run:
# basically what you have now....
# check for collision (in pseudo-code) check for game-ending events
if player1.collides_with_death...:
end_condition=True
if player1.falls_into_pit()...:
end_condition=True
# use the boolean variable to decide what to do next, and in next loop
if end_condition:
draw_end_screen()
else:
redrawwindow()
pygame.display.update()
添加回答
举报