mirror of
https://github.com/tanema/light_world.lua.git
synced 2024-12-24 20:24:19 +00:00
better screen range checking
This commit is contained in:
parent
4a969a0aec
commit
3c559635e9
@ -507,12 +507,15 @@ function body:isInLightRange(light)
|
||||
end
|
||||
|
||||
function body:isInRange(l, t, w, h, s)
|
||||
local bx, by, bw, bh
|
||||
local radius
|
||||
if self.type == 'circle' then
|
||||
bx, by, bw, bh = self.x - self.radius, self.y - self.radius, self.radius * 2, self.radius * 2
|
||||
radius = self.radius
|
||||
else
|
||||
bx, by, bw, bh = self.x, self.y, self.width, self.height
|
||||
radius = (self.width > self.height and self.width or self.height)
|
||||
end
|
||||
|
||||
local bx, by, bw, bh = self.x - radius, self.y - radius, radius * 2, radius * 2
|
||||
|
||||
return self.visible and (bx+bw) > (-l/s) and bx < (-l+w)/s and (by+bh) > (-t/s) and by < (-t+h)/s
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user