entity.h 908 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include "game_engine.h"
  3. #include "director.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. typedef struct Entity Entity;
  8. typedef struct {
  9. float x;
  10. float y;
  11. } Vector;
  12. #define VECTOR_ZERO ((Vector){0, 0})
  13. typedef struct {
  14. void (*start)(Entity* entity);
  15. void (*stop)(void* context);
  16. void (*update)(Entity* entity, Director* director, void* context);
  17. void (*render)(Entity* entity, Director* director, Canvas* canvas, void* context);
  18. } EntityBehaviour;
  19. #define ENTITY_BEHAVIOUR_EMPTY ((EntityBehaviour){NULL, NULL, NULL, NULL})
  20. void entity_behaviour_set(Entity* entity, EntityBehaviour behaviour);
  21. void entity_context_set(Entity* entity, void* context);
  22. Vector entity_pos_get(Entity* entity);
  23. void entity_pos_set(Entity* entity, Vector position);
  24. void entity_pos_add(Entity* entity, Vector delta);
  25. void* entity_context_get(Entity* entity);
  26. #ifdef __cplusplus
  27. }
  28. #endif