Imagine that I have an object Box. I create the box with the property dy++ so that it is falling down all the time until it hits the ground. But if I want to create another object and put it above the first so that a collision is made and the box lands on the other box and so on. What is the best way to do this?
I've been trying something like
for(Box b1 : boxes){
for(Box b2 : boxes){
if(b1.intersects(b2) && b1.direction == down){
collision = true
blablablablabla
}
}
Yeah, not exactly like that, but that kind of method. But that does not work very well for me. Do you have an idea how to make it work properly?






