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
 | 
			
		||||
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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue