#--------------input-------------#
def getmove():
global room,posx,posy,moves,dead,inventory,foods,drinks,food,water
move=input()
if move == 'e':
posx=posx+1
if move == 'w':
posx=posx-1
if move == 's':
posy=posy+1
if move == 'n':
posy=posy-1
if 'grab' in move:
additem(move,inventory)
if move == 'inventory':
print(inventory)
if move == 'save':
moves-=1
food+=1
water+=1
save(posx,posy,moves,dead,food,water)
if move == 'load_save':
moves-=1
food+=1
water+=1
load_save()
if move == 'search':
search(inventory)
if move == 'eat':
food+=4
eat()
if move == 'drink':
water+=4
drink()
if food <= 2:
print('You start to feel hungry')
if water <=2:
print('You start to feel thirsty')
if food == 0 or water == 0:
dead = True
seeifdead(room,posx,posy,moves,dead,inventory,foods,drinks)
moves+=1
food-=1
water-=1
else:
print('I dont understand')
moves-=1
food+=1
water+=1
#print(posx,posy,moves,dead)
getroom(posx,posy,moves,dead,room)
#print(posx,posy,moves,dead)
getmove()
我在大学的时候为一个基本的游戏写了一个python程序,它还在运行,但是几年后它停止了运行,我看不出有什么问题
当我运行这个程序时,它会抱怨else语句的语法无效,但我看不出它有什么问题,不过,总的来说,我已经从编程中休息了将近两年。有人能帮我理解我做错了什么吗?你知道吗
如果需要我也可以添加整个程序这只是输入的一部分
事先非常感谢:)
检查这部分代码:
在if和后面的else之间有代码。 这将导致语法错误。你知道吗
把它和上面的部分比较一下,看看有什么不同。你知道吗
相关问题 更多 >
编程相关推荐