entity.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include "game_engine.h"
  3. #include "director.h"
  4. #include <stdlib.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. typedef struct Entity Entity;
  9. typedef struct {
  10. float x;
  11. float y;
  12. } Vector;
  13. #define VECTOR_ZERO ((Vector){0, 0})
  14. typedef struct {
  15. void (*start)(Entity* self, Level* level, void* context);
  16. void (*stop)(Entity* self, Level* level, void* context);
  17. void (*update)(Entity* self, Director* director, void* context);
  18. void (*render)(Entity* self, Director* director, Canvas* canvas, void* context);
  19. void (*collision)(Entity* self, Entity* other, Director* director, void* context);
  20. size_t context_size;
  21. } EntityDescription;
  22. const EntityDescription* entity_description_get(Entity* entity);
  23. Vector entity_pos_get(Entity* entity);
  24. void entity_pos_set(Entity* entity, Vector position);
  25. void* entity_context_get(Entity* entity);
  26. typedef struct Collider Collider;
  27. void entity_collider_add_circle(Entity* entity, float radius);
  28. void entity_collider_add_rect(Entity* entity, float width, float height);
  29. #ifdef __cplusplus
  30. }
  31. #endif