Files
Quadtree/include/quadtree.h
2020-01-06 00:39:15 +01:00

54 lines
951 B
C

/*
** EPITECH PROJECT, 2019
** quadtree
** File description:
** quadtree
*/
#pragma once
#include <stdbool.h>
#define MAXCOL 1024
#define MAX_ENTITY 20
typedef struct quadtree quadtree;
typedef struct qt_intrect
{
float x;
float y;
int h;
int w;
} qt_intrect;
typedef struct qt_object
{
int id;
qt_intrect rect;
int layer;
} qt_object;
typedef struct qt_collision
{
float distance_left;
float distance_right;
float distance_top;
float distance_down;
int *collide_with;
} qt_collision;
struct quadtree
{
qt_intrect rect;
int capacity;
void *objects;
};
quadtree *qt_create(qt_intrect rect, int capacity);
int qt_add(quadtree *tree, qt_object obj);
qt_collision collision_get_info(quadtree *tree, int entity_id);
bool qt_collide(qt_intrect r1, qt_intrect r2);
qt_object *qt_getobj(quadtree *tree, int id);
int qt_update(quadtree *tree, qt_object obj);
void qt_destroy(quadtree *tree);