mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-13 22:49:51 -04:00
Fixed distanceSquaredToPoint
This commit is contained in:
parent
f0fbfa6cbc
commit
7c8c2e9381
1 changed files with 1 additions and 0 deletions
|
@ -68,6 +68,7 @@ class Rectangle
|
|||
|
||||
distanceSquaredToPoint: (p) ->
|
||||
# Doesn't handle rotation; just supposed to be faster than distanceToPoint
|
||||
p = Vector.subtract(p, @getPos())
|
||||
dx = Math.max(Math.abs(p.x) - @width / 2, 0)
|
||||
dy = Math.max(Math.abs(p.y) - @height / 2, 0)
|
||||
dx * dx + dy * dy
|
||||
|
|
Loading…
Reference in a new issue