#include "world.h"
#include <math.h>
#include "config.h"
#include "collision.h"
#include "player.h"

void checkCollision(){
    float objdet[MAX_ENTITIES][3];

    //array structure:
    // [entitiy #1][x,y,size]
    // [entitiy #2][x,y,size]
    // etc...

    for (int i = 0; i < MAX_ENTITIES; i++){
        Entity *e = &entities[i];
        if (!e->active){
            continue;
        }
        objdet[i][0]=e->position.x;
        objdet[i][1]=e->position.y;
        objdet[i][2]=e->size;
    }
    for(int u=0; u<=MAX_ENTITIES; u++){
        Entity *en1 = &entities[u];
        for(int j=0; u<=MAX_ENTITIES; u++){
            Entity *en2 = &entities[j];
            if(u!=j){
                if(objdet[u][0]<objdet[j][0]){
                    ApplyForce(
                    en1,
                    (Vector2){10000, 0}
                    );
                    ApplyForce(
                    en2,
                    (Vector2){-10000, 0}
                    );
                }
            }
        }
    }

    
}
