和运营商的不一致
And Operator's Inconsistency
如果满足这些条件,则以下代码运行代码:
- 用户点击名为
box
的表面
box
必须在至少 一个方向上移动
if ((boxLeft < pygame.mouse.get_pos()[0] < boxLeft + BOX_SIZE) and (boxTop < pygame.mouse.get_pos()[1] < boxTop + BOX_SIZE)) and ((dx != 0) and (dy != 0)):
这不会发生。相反,代码仅在盒子在 both 方向移动时运行(如果两者都 not dx and dy == 0)
我想你的意思是 ((dx != 0) or (dy != 0))
这样它就可以检测到它何时只朝一个方向移动。
如果满足这些条件,则以下代码运行代码:
- 用户点击名为
box
的表面
box
必须在至少 一个方向上移动
if ((boxLeft < pygame.mouse.get_pos()[0] < boxLeft + BOX_SIZE) and (boxTop < pygame.mouse.get_pos()[1] < boxTop + BOX_SIZE)) and ((dx != 0) and (dy != 0)):
这不会发生。相反,代码仅在盒子在 both 方向移动时运行(如果两者都 not dx and dy == 0)
我想你的意思是 ((dx != 0) or (dy != 0))
这样它就可以检测到它何时只朝一个方向移动。