我正在尝试用Pygame制作一个Python“Sokoban”游戏,我遇到了一些麻烦,当它真正涉及到用Key\u UP/Key\u 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
目前没有回答
相关问题 更多 >
编程相关推荐