i = 0; while( i < 10 * 15 ) { int move_down = Yes; /* When there's a space below the square, move it down until it hits the bottom or the square below it. */ if( squares[i].active ) { struct square_t* sq = &squares[i]; int j = 0; while( j < 10 * 15 ) { /* Avoid testing the same square against itself */ /* Also skip inactive squares */ if( i == j || !squares[j].active ) { j++; continue; } /* Skip squares that are already at the bottom */ if( squares[j].pos.y - squares[j].size.y >= ( ( SQUARE_SIZE + 3.0f ) * 14.0f ) ) { j++; move_down = No; continue; } /* Is this square directly below the one we're testing? */ if( sq->pos.x == squares[j].pos.x ) { if( sq->pos.y == ( squares[j].pos.y - ( SQUARE_SIZE + 3.0f ) ) ) { move_down = No; break; } } j++; } if( move_down ) squares[i].pos.y += 1.0f; } i++; }

I hate to just dump some random code on you all, but I need to have this concept ready ASAP. I've played around with the signs a bit, and each time I get some different and funky results, but never the one I need. And the +3.0f is just the amount of space between each square on the screen.

Any ideas? Thanks.