summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--obj.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/obj.lua b/obj.lua
index bdf30dc..f93eae9 100644
--- a/obj.lua
+++ b/obj.lua
@@ -54,6 +54,16 @@ function obj.in_box(x1, y1, x2, y2)
end)
end
+function obj.in_circle(x1, y1, r)
+ return coroutine.wrap(function()
+ for o in obj.in_box(x1-r, y1-r, x1+r, y1+r) do
+ if (x1-o.data.pos[1])^2 + (y1-o.data.pos[2])^2 <= r^2 then
+ coroutine.yield(o)
+ end
+ end
+ end)
+end
+
function obj.at(x, y)
return coroutine.wrap(function()
for o in obj.in_box(