Python 3.3 では、2 つの while true を使用してゲームを作成しています。実行すると、2 番目ではなく最初の while true にループします。なぜこれを行うのですか?次のように私のコードの最初の部分:
while True:
# Callum Dashfield
print ("You must answer all questions in block capitals")
print ("Welcome to maze runner")
print ("To learn about the controls press C")
print ("To learn the about the different types T")
print ("To play press START")
run = input ()
#Controls
if run == "C":
print ("To attack press H")
print ("To walk forward press W")
print ("To turn left press A")
print ("To turn right press D")
print ("To turn around press S")
print ("To block press B")
print ("To see what you are carrying press E")
print ("To open stats press Q")
print ("To open this screen press C")
print ("To go back to the main menu press M")
return_to_menu = input()
if return_to_menu != "M":
break
これは 2 番目のループです。
while True:
solider_close = ['7', '8' , '9', '10']
from random import choice
solider_long = ['1', '2', '3']
from random import choice
solider_speed = [ '4', '5', '6']
from random import choice
solider_block = [ '4', '5', '6']
print ("You choose solider")
print ("Your stats: close combat - " + choice(solider_close))
print (" long range combat - " + choice(solider_long))
print (" long range combat - " + choice(solider_speed))
print (" long range combat - " + choice(solider_block))
print ("Press S to continue")
continues = input ()
if continues == "Y":
#RESET
else:
break