Sorry for the title, it seems kind of weird but it's hard to explain. I'll be using JavaScript syntax for this as it's the language I am most familiar with.
For example, let's say I have an array called Boxes
that houses 4 objects:
Boxes = [
{x: 1, y: 1, width: 100, height: 10},
{x: 1, y: 1, width: 130, height: 10},
{x: 1, y: 1, width: 150, height: 10},
{x: 1, y: 1, width: 120, height: 10}
]
I can use:
for(var box of Boxes){
console.log(box)
}
To loop through them. However, this is where my mind goes blank. How exactly do I create a loop that will check the box
against themselves?
For example, if these objects were echo'd out in a game, they'd overlap. I would need to loop through them, check them against themselves to find out their new positions, right? Or am I overthinking this?