2016-05-12 9 views
0

私はあなたが迷路を通り、声を逃れようとするゲームを作ろうとしていますが、プレイヤーは「Game Over」それはオフのまま場所に運び、私は多くのことをしようとした研究が、私はそれを把握するように見えることはできませんしました、私は初心者Python Maze Game trouble

`

インポート時 輸入OSだ

print ("Your adventure starts as a young boy, running away from home becuase you're a rebel") 
    time.sleep(2) 
    print ("You find the famous labyrinth, do you go in?") 
    time.sleep(2) 
    answer = input("Make your choice, Yes OR No") 
    time.sleep(2) 
    print ("The answer",answer ,"got you stuck in a hole") 
    time.sleep(2) 
    print ("But you find a secret passage") 
    answer = input("Do you go through the door, Yes or No?") 
    if answer == "No": 
      time.sleep(2) 
      print ("Game Over.") 
    elif answer == "Yes": 
     time.sleep(2) 
     print("You hear a strange voice") 
     time.sleep(2) 
    answer = input("What do you say to the Voice, Hello or Who are you?") 
    if answer == "Hello": 
     print ("Hello") 
    elif answer == "Who are you?": 
     print ("Im your worst nightmare") 
    time.sleep(2) 
    print("You try and escape the labyrinth and turn a large gate with a gnome on the over end") 
    answer = input("Do you open the gate, Yes Or No?") 
    if answer == "Yes": 
     time.sleep(3) 
     print ("Game Over, you get brutally killed by a gnome, good job") 
     os._exit(0) 
    elif answer == "No": 
     time.sleep(3) 
     print ("You go the other way and see a light at the end of the tunnel") 
    answer = input("You see your family outside crying and waiting for you, do you go with them?") 
    if answer == "Yes": 
     print("You have a nice ending and you're sorry you ran away") 
     print("You have been graded: ") 
    elif answer == "No": 
     print("God smites you for being stupid.") 

     os._exit(0)` 
+1

申し訳ありませんのtruthy一部で次に何が起こるかラップすなわち必要がある場合は、あなたの制御フローは、前方にのみパスを持っていることを確認してくださいあまりにも厄介な、うまくいけば、あなたはそれを読む時間があります。 – AGAC

+1

あなたは組織で仕事をすることができます。空白を使用する(必要に応じて過度に)。 – Jerrybibo

+0

完全に一致していました。これを行うには急いでいました。ちょっと趣味のものがありません。 – AGAC

答えて

2

このブロックを取る。たとえば、

ユーザーが「いいえ」と入力すると「Game Over」と表示されますが、それは正しいと思います。ただし、プログラムの制御フローは、ブロックif/elseを過ぎても続きます。何をする必要がsys.exit()のようなものを使用して、プログラムの終了であるかのコードがある場合、それはif/elseブロック

if answer == "No": 
     time.sleep(2) 
     print ("Game Over.") 
elif answer == "Yes": 
    time.sleep(2) 
    print("You hear a strange voice") 
    time.sleep(2) 

    # put continuation here 
+2

または、print( "Game Over。") ';)の後に' return'文を追加してください; – alfasin

+0

ありがとうございました良いアイデアです、今それをテストしてください – AGAC

+0

作品、素晴らしい仕事。私は愚かなああだった – AGAC