Optimiced collision so noncollidable objects are skipped first
This commit is contained in:
parent
cbf29ced65
commit
dedb0d884c
|
@ -24,18 +24,18 @@ end
|
||||||
|
|
||||||
-- returns true if theres a collision at that point. also marks collisioned tile as collision true
|
-- returns true if theres a collision at that point. also marks collisioned tile as collision true
|
||||||
function isThereObjectAt(x,y,objectType)
|
function isThereObjectAt(x,y,objectType)
|
||||||
local result = false
|
|
||||||
for _, collision in pairs(objectType) do
|
for _, collision in pairs(objectType) do
|
||||||
if x >= collision.from.x
|
if collision.disable then
|
||||||
|
-- Dont calculate if dissabled
|
||||||
|
elseif x >= collision.from.x
|
||||||
and x <= collision.to.x
|
and x <= collision.to.x
|
||||||
and y >= collision.from.y
|
and y >= collision.from.y
|
||||||
and y <= collision.to.y
|
and y <= collision.to.y then
|
||||||
and collision.disable ~= true then
|
|
||||||
result = true
|
|
||||||
collision.collision = true
|
collision.collision = true
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return result
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function isThereAnyCollisionAt(x,y)
|
function isThereAnyCollisionAt(x,y)
|
||||||
|
|
Loading…
Reference in New Issue