我对Python很新。当我等待一些东西给我的Pi时,在Windows上运行。 我正在写一个游戏,用户通过文本输入穿过塔楼。只允许用户在Python中执行一次函数?
用户可以使用“a”“d”“w”环顾房间收集sutff。但如果用户已经看过“a”(这是“向左看”),我需要让他们知道他们已经在那里。 这是我的代码,但它有一个明显的缺陷。
#if user hits 'a' they look left
def roomOneLeft():
print '-- You search some loose rubble and find some cloth'
return roomOneMoves()
#where the user selects a movement
def roomOneMoves():
left = 0
move = raw_input("")
if left == 1:
print 'you have already looked here'
return roomOneMoves()
if move == "a":
left = left + 1
roomOneLeft()
我可以设置“左”静态?蚂蚁研究如何将它设置为像java这样的全局变量。这显然不起作用,因为它返回时,它将自己设置为0.任何帮助将不胜感激!
你是一颗宝石!谢谢 –
最好为你的问题选择一个答案,以便你将继续得到支持...... – ATOzTOA