Hello, I am beginner in gms. And I am pondering on how to stack boxes within a space (the red space in the pictures). I want the boxes to be stacked automatically as I add them, and they can be any height or width.
I want the boxes to be as close to center as possible, as shown in this picture:
If I add another box, the total width of the 2 boxes is still centered, as in this picture:
If I add a 3rd box, and it won't fit in the red space, it jumps up and is as close as possible to the highest box, like in this picture:
So far so good, I manage to get this to work. But I realized a problem. I checked this manually, with if statements for everything, but this approach becomes really hard now, there is so many scenarios to check for. What if it looks like in this picture:
I think I need another approach, how would you program this? Does anyone have any good idea or tips on how to tackle this problem?
I want the boxes to be as close to center as possible, as shown in this picture:
If I add another box, the total width of the 2 boxes is still centered, as in this picture:
If I add a 3rd box, and it won't fit in the red space, it jumps up and is as close as possible to the highest box, like in this picture:
So far so good, I manage to get this to work. But I realized a problem. I checked this manually, with if statements for everything, but this approach becomes really hard now, there is so many scenarios to check for. What if it looks like in this picture:
I think I need another approach, how would you program this? Does anyone have any good idea or tips on how to tackle this problem?