From dedb0d884c1db92dea2033fc6f1f747f265e825a Mon Sep 17 00:00:00 2001 From: bizcochito Date: Sat, 5 Feb 2022 12:38:08 +0100 Subject: [PATCH] Optimiced collision so noncollidable objects are skipped first --- data/scripts/objects.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/data/scripts/objects.lua b/data/scripts/objects.lua index c708150..a183e16 100644 --- a/data/scripts/objects.lua +++ b/data/scripts/objects.lua @@ -24,18 +24,18 @@ end -- returns true if theres a collision at that point. also marks collisioned tile as collision true function isThereObjectAt(x,y,objectType) - local result = false 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 y >= collision.from.y - and y <= collision.to.y - and collision.disable ~= true then - result = true + and y <= collision.to.y then collision.collision = true + return true end end - return result + return false end function isThereAnyCollisionAt(x,y)