freak-engine/include/entity.h

31 lines
822 B
C

#pragma once
#include <gint/display.h>
struct Entity {
int x;
int y;
int hb_x;
int hb_y;
int hb_w;
int hb_h;
int layer;
color_t hb_color;
};
#define ENTITY_GRID_SIZE 256
extern struct Entity *g_entity_grid[ENTITY_GRID_SIZE];
void entity_init(struct Entity *, int x, int y, int hb_x, int hb_y, int hb_w,
int hb_h, int layer, color_t hb_color);
void entity_deinit(struct Entity *);
void entity_draw_hitbox(struct Entity *);
void entity_grid_draw_hitboxes(void);
/* return first entity colliding on mask */
struct Entity *entity_collide(struct Entity *, int mask);
/* return bool */
int entity_collide_with(struct Entity *self, struct Entity *other, int mask);
/* return bitmask
* bit 1: collide on x
* bit 2: collide on y */
int entity_move(struct Entity *e, int mask, int move_x, int move_y);