python - 和运营商的不一致
问题描述
如果满足这些条件,以下代码将运行代码:
- 用户点击一个名为
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)):
这不会发生。相反,代码仅在盒子双向移动时运行(如果两者都没有dx 和 dy == 0)
解决方案
我认为您打算这样做((dx != 0) or (dy != 0))
,它可以检测到它何时仅朝一个方向移动。
推荐阅读
- woocommerce - PayPal WooCommerce 使用一个 PayPal 帐户连接多个网站
- amazon-web-services - 如何在 AWS S3 网站 CloudFront 中设置别名重定向?
- matlab - 使用 fmincon 函数的最优控制问题
- python - 如何从 Python3 的列表中调用我自己的方法?
- c# - ODBC调用存储过程
- javascript - 如何让 webpack-dev-server 获取最新的更改
- swift - 标签栏自定义按钮图像不显示
- android - 如何使用 kotlin 将 ISO 3166-1 值转换为国家名称
- google-apps-script - 使用 Google Script 和 Notion API 创建页面时未定义父级
- reactjs - 使用 GitHub Action [CI/CD] 部署 AWS S3 时如何设置自定义环境变量以响应应用程序