Python 3.x 在以下代码中,为什么距离必须小于27
我正在观看pygame的YT教程,该人对碰撞做了如下操作:Python 3.x 在以下代码中,为什么距离必须小于27,python-3.x,pygame,collision-detection,Python 3.x,Pygame,Collision Detection,我正在观看pygame的YT教程,该人对碰撞做了如下操作: def isCollision(x1,y1,x2,y2): distance = root of (x1 - x2)^2 + (y1 - y2)^2 #i know this is not how you do it but using the math module takes too long if distance > 27: return True else: r
def isCollision(x1,y1,x2,y2):
distance = root of (x1 - x2)^2 + (y1 - y2)^2
#i know this is not how you do it but using the math module takes too long
if distance > 27:
return True
else:
return False
我想问他是如何决定距离需要小于27的。我是说为什么是27???
如果代码不够,视频将由freeCodeCamp.org及其名为Pygame的初学者教程提供。代码在说明中。游戏中的角色不是单点对象,它们在代表对象的点周围占据一些空间。考虑这些图像中的圆对象: 两个对象中心之间的距离分别为
>0
和