【问题标题】:How to make the game restart (python turtle snake game)如何让游戏重启(python龟蛇游戏)
【发布时间】:2020-07-03 13:39:46
【问题描述】:

所以我想在玩家撞墙或撞到自己(输掉一场比赛)后让游戏重新开始我尝试使用 tkinter 但现在不知道该怎么处理我只是感到困惑。 我还想问有没有办法询问玩家在输球后是否想再次比赛或类似的功能。 我可以在海龟上使用按钮吗?

【问题讨论】:

标签: python turtle-graphics


【解决方案1】:

方法如下:

import turtle

while True:
    # Your game code
    again = input("Do you want to play again? ")
    if again == 'yes':
        screen.clear()
    else:
        print('Bye!')
        break
    # If the player enters `yes`, the screen will be cleared, then the program will loop back to the top of this while loop

【讨论】:

  • 对不起,我粘贴了剪贴板上的内容,我不是故意的。 +1
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-20
  • 2014-08-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多