summaryrefslogtreecommitdiff
path: root/utils/utils.lua
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-02-18 20:41:11 +0800
committerEltrac <hi@guhub.cn>2025-02-18 20:41:11 +0800
commit2aabcd0483323eaa968f0f891a87dc9d1a7092f1 (patch)
treecbf0950565e17c5bc1077565fe00eb121dd88df9 /utils/utils.lua
parent1ca1b5d3793b8bf7567160485b994d01832a1073 (diff)
style: remove comment
Diffstat (limited to 'utils/utils.lua')
-rw-r--r--utils/utils.lua5
1 files changed, 1 insertions, 4 deletions
diff --git a/utils/utils.lua b/utils/utils.lua
index 8425b1d..3e06b16 100644
--- a/utils/utils.lua
+++ b/utils/utils.lua
@@ -15,16 +15,13 @@ function utils.playerCollideWith(x, y, r)
end
function utils.circleRectCollide(cx, cy, r, rx, ry, rw, rh)
- -- 计算圆心到矩形的水平和垂直距离
local nearestX = math.max(rx, math.min(cx, rx + rw))
local nearestY = math.max(ry, math.min(cy, ry + rh))
- -- 计算圆心到矩形最近边的距离
local dx = cx - nearestX
local dy = cy - nearestY
- local distanceSquared = dx * dx + dy * dy -- 避免开方,提高性能
+ local distanceSquared = dx * dx + dy * dy
- -- 如果圆的半径大于或等于这个距离,表示有碰撞
return distanceSquared <= r * r
end