objects = { entities = {}, collisions = {}, platforms = {}, ladders = {} } -- level functions function objects.DrawCollisions() for _, col in pairs(objects.collisions) do col:Draw(1) end for _, plat in pairs(objects.platforms) do if plat.disable == true then plat:Draw(2) end if plat.disable == false then plat:Draw(1) end end for _, ladder in pairs(objects.ladders) do ladder:Draw(2) end 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 _, col in pairs(objectType) do if x >= col.from.x and x <= col.to.x and y >= col.from.y and y <= col.to.y and col.disable ~= true then result = true col.collision = true end end return result end function isThereAnyCollisionAt(x,y) local result = false if not result then result = isThereObjectAt(x,y,objects.collisions) end if not result then result = isThereObjectAt(x,y,objects.ladders) end if not result then result = isThereObjectAt(x,y,objects.platforms) end return result end -- flags function SetCollisionFlags(player) for _, col in pairs(objects.collisions) do col.collision = false end for _, plat in pairs(objects.platforms) do plat.collision = false if player.pos.y < plat.from.y then plat.disable = false else plat.disable = true end end for _, ladder in pairs(objects.ladders) do ladder.collision = false end end