entity_i.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #pragma once
  2. #include "entity.h"
  3. #include "game_manager.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. typedef enum {
  8. ColliderTypeCircle,
  9. ColliderTypeRect,
  10. } ColliderType;
  11. typedef struct {
  12. ColliderType type;
  13. union {
  14. struct {
  15. float radius;
  16. } circle;
  17. struct {
  18. float half_width;
  19. float half_height;
  20. } rect;
  21. };
  22. } Collider;
  23. struct Entity {
  24. Vector position;
  25. const EntityDescription* description;
  26. void* context;
  27. Collider* collider;
  28. Vector collider_offset;
  29. bool collider_dirty;
  30. };
  31. Entity* entity_alloc(const EntityDescription* behaviour);
  32. void entity_free(Entity* entity);
  33. void entity_call_start(Entity* entity, GameManager* manager);
  34. void entity_call_stop(Entity* entity, GameManager* manager);
  35. void entity_call_update(Entity* entity, GameManager* manager);
  36. void entity_call_render(Entity* entity, GameManager* manager, Canvas* canvas);
  37. void entity_call_collision(Entity* entity, Entity* other, GameManager* manager);
  38. bool entity_collider_check_collision(Entity* entity, Entity* other);
  39. bool entity_collider_exists(Entity* entity);
  40. int32_t entities_get_count(void);
  41. #ifdef __cplusplus
  42. }
  43. #endif