Hello, just starting to study game development and I came across this piece of code. I’ve been looking through the docs and trying to completely understand what’s going on, but having a bit of a hard time grasping it fully. I know this piece of code detects whether or not two objects have collided, but if someone can explain it to me in plain English that would be awesome.
[code]
function HitTestObjects(obj1, obj2)
local left = obj1.contentBounds.xMin <= obj2.contentBounds.xMin and obj1.contentBounds.xMax >= obj2.contentBounds.xMin
local right = obj1.contentBounds.xMin >= obj2.contentBounds.xMin and obj1.contentBounds.xMin <= obj2.contentBounds.xMax
local up = obj1.contentBounds.yMin <= obj2.contentBounds.yMin and obj1.contentBounds.yMax >= obj2.contentBounds.yMin
local down = obj1.contentBounds.yMin >= obj2.contentBounds.yMin and obj1.contentBounds.yMin <= obj2.contentBounds.yMax
return (left or right) and (up or down)
end
[/code] [import]uid: 132483 topic_id: 34246 reply_id: 334246[/import]
