Hello I am trying to create a function Gravity that make all the black pixels of a Quadtree to "fall" if they can (if there is a white pixel under).
for instance Gravity(Qt1) gives Qt2 :

The Quadtree class:
typedef struct Qtree{
bool allblack;
struct Qtree * son[4];
}Qtree;
I have made some auxiliariy functions: create a black pixel
Qtree* create_Black(){
Qtree* I -> malloc(sizeof(Qtree));
I->son[0] = I->son[1] = I->son[2] = I->son[3] = NULL
return I;
create a white pixel
Qtree* create_White(){
return NULL;
create a Qtree based on 4 sons
Qtree* create_Comp(Qtree* i0, Qtree* i1, Qtree* i2, Qtree i3){
Qtree* I = malloc(sizeof(Qtree));
I->son[0] = i0;
...
return I;
}
I already have done some code that exchanges black pixel but I can obtain the result wanted :( If some guys could help me, I can't find any ressources on internet