我正在用python编写一个蛇游戏,蛇可以向上、向左和向右移动,当我试图向下移动(使用箭头(时总是会出现错误。我正在处理碰撞,因为蛇会与自己碰撞(蛇头碰到身体(,屏幕会显示"游戏结束-你输了"。
Traceback (most recent call last): File "/Users/myname/Documents/SnakeGame.py", line 107, in <module> collision_y = playerRect.centrex AttributeError: 'pygame.Rect' object has no attribute 'centrex'
您在
elif dy < 0:
中的collision_y = playerRect.centrex
线上有一个拼写错误的中心