def playerMove (board,player):
userInput = input("Enter a direction NSWE: ").upper()
if userInput == "N":
if (player == 0):
board[player] = '.'
player += 1
board[player] = '@'
elif userInput == "S":
if (player(board)-1):
board[player] = '.'
player += 1
board[player] = '@'
elif userInput == "E":
if (player < len(board)-1):
board[player] = '.'
player += 1
board[player] = '@'
elif userInput == "W":
if (player['x'] > 0):
board[player] = '.'
player -= 1
board[player] = '@'
我希望单人游戏向上,向下,向左和向右移动。我迷路了。我是初学者,我不知道从哪里开始。
答案 0 :(得分:0)
从你的问题中可以清楚地知道究竟发生了什么,或者应该继续下去。
但是,从您对电路板的引用,您可能希望跟踪播放器的x和y坐标。现在似乎只有一个维度被跟踪,这相当于只能向左或向右移动。
您可能希望查看Python的类(https://docs.python.org/2/tutorial/classes.html)并为棋盘,玩家等定义一个类。它可以更容易地跟踪什么,以及在哪里。