fix: fix the actor in rect query

* use x2/y2 as secondary limit comparison
* return the query and not an non-initilized variable
This commit is contained in:
Kazhnuz 2020-09-13 13:28:41 +02:00
parent ef4bf26ba6
commit bc45f866c2

View file

@ -142,14 +142,14 @@ function BaseWorld:getActorsInRect(x, y, w, h)
local query = {} local query = {}
local x2, y2 = x + w, y + h local x2, y2 = x + w, y + h
for i,v in ipairs(self.actors) do for i,v in ipairs(self.actors) do
if (v.x >= x) and (v.x + v.w >= x1) and if (v.x >= x) and (v.x + v.w >= x2) and
(v.y >= y) and (v.y + v.h >= y1) then (v.y >= y) and (v.y + v.h >= y2) then
table.insert(query, v) table.insert(query, v)
end end
end end
return v return query
end end