1 回答

TA貢獻1780條經驗 獲得超4個贊
這是一個可以幫助您的框架。與上面的評論相同。您需要一個布爾變量來跟蹤何時顯示結束屏幕(發生了不好的事情),然后使用它來決定在主循環中繪制哪個屏幕......
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()
添加回答
舉報