Guest User

Untitled

a guest
Nov 23rd, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include "stdio.h"
  2. #include "stretchy_buffer.h"
  3.  
  4. typedef enum {
  5. DRAWABLE = 1 << 0,
  6. COLLIDABLE = 1 << 1,
  7. CONTROLLABLE = 1 << 2,
  8. } flag_t;
  9.  
  10. typedef struct entity_t entity_t;
  11. typedef struct world_t world_t;
  12. typedef struct callback_t callback_t;
  13.  
  14. struct callback_t {
  15. unsigned int filter;
  16. void(*func)(world_t *, entity_t *);
  17. };
  18.  
  19. struct entity_t {
  20. unsigned long type, destroy, id;
  21. void *self;
  22. };
  23.  
  24. struct world_t {
  25. unsigned int count;
  26. entity_t *entities;
  27. callback_t *cb;
  28. };
  29.  
  30. world_t *world_new() {
  31. world_t *self = calloc(1, sizeof(*self));
  32. self->count = 0;
  33. self->entities = NULL;
  34. self->cb = NULL;
  35. return self;
  36. }
  37.  
  38. void world_push(world_t *self, entity_t *e) {
  39. sb_push(self->entities, e);
  40. self->count = sb_count(self->entities);
  41. }
  42.  
  43. int main(void) {
  44. // entity_t bar = { .type = DRAW | COLLISION, .data = NULL };
  45. return 0;
  46. }
Add Comment
Please, Sign In to add comment