我正在尝试使用Pygame制作一个Python“Sokoban”游戏,我实际上遇到了一些麻烦,当它实际上归结为使用Key_UP / Key_Down等功能移动我的播放器时,我想我有想法,但我的代码不是工作是因为我对Pygame本身并不太熟悉。
任何帮助将不胜感激! :)
def moveSobRight():
x = maze.getCharAtPos(sob.getRow(), sob.getCol() + 1)
y = maze.getCharAtPos(sob.getRow(), sob.getCol() + 2)
print "x/y init works"
if x == "#":
print "You have hit a wall, you cannot move!"
elif x == " ":
print "This is a space!"
sob.moveRight()
maze.placeSob(sob.getChar(), sob.getRow(), sob.getCol())
maze.clearAtPos(sob.getRow(), sob.getCol()-1)
elif (x == "@" and y == " "):
print "You have collided with a sprout, the sprout will move away now"
crate.pushboxright()
maze.placeCrate(crate.getRow(), crate.getcol())
sob.moveRight()
maze.placeSob(sob.getChar(), sob.getRow(), sob.getCol())
maze.clearAtPos(sob.getRow(), sob.getCol()-1)
else:
pass