Here's something you might find useful: an function that checks if two rectangles are overlapping. Or, more correctly, it tests if they're not overlapping and then returns the opposite. Just give it the coords and dimensions of the first rectangle, and then the coords and dimensions of the second.heartmonster wrote:Aaah! Thank you guys so much! This is more helpful than you can imagine. So much of the code out there is like 100 steps above what I can comprehend at this level.
Anyway, I made something. This is my first ever programmed thing I've ever made so it's very simple. But I'm happy with it.
Code: Select all
function overlap(x1,y1,w1,h1, x2,y2,w2,h2)
return not (x1+w1 < x2 or x2+w2 < x1 or y1+h1 < y2 or y2+h2 < y1)
end