dd_world.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef DD_WORLD_H
  2. #define DD_WORLD_H
  3. /* data that each world has
  4. */
  5. extern struct dd_world {
  6. void (*create)(struct dd_world *);
  7. void (*onload)(struct dd_world *);
  8. void (*update)(struct dd_world *);
  9. void (*resize)(struct dd_world *);
  10. void (*draw)(struct dd_world *);
  11. void (*key_input)(struct dd_world *, unsigned char key);
  12. void (*mouse_input)(struct dd_world *, int button, int type);
  13. void (*clean)(struct dd_world *);
  14. } *cworld, *nworld;
  15. /*
  16. * new world data
  17. */
  18. extern void (*nworld_constructor)(struct dd_world*);
  19. extern int nworld_size;
  20. extern int nworld_ready;
  21. extern int nworld_loading;
  22. /* constructor destructor
  23. */
  24. struct dd_world *dd_world_create_dynamic();
  25. void dd_world_clean();
  26. /*
  27. * handy function to change between worlds
  28. *
  29. */
  30. #define dd_world_prepare(WORLD, PERCENT) nworld_constructor = WORLD ## _create; nworld_size = sizeof(struct WORLD); nworld_ready = 0; avdl_assetManager_setPercentage(PERCENT);
  31. #define dd_world_ready() nworld_ready = 1;
  32. #define dd_world_prepareReady(WORLD, PERCENT) dd_world_prepare(WORLD, PERCENT); dd_world_ready();
  33. void dd_world_change(int size, void (*constructor)(struct dd_world *));
  34. void dd_world_create(struct dd_world *);
  35. void dd_world_onload(struct dd_world *);
  36. void dd_world_update(struct dd_world *);
  37. void dd_world_draw(struct dd_world *);
  38. void dd_world_key_input(struct dd_world *, unsigned char key);
  39. void dd_world_mouse_input(struct dd_world *, int button, int type);
  40. void dd_world_clean(struct dd_world *);
  41. // default world
  42. extern int dd_default_world_size;
  43. extern void (*dd_default_world_constructor)(struct dd_world *);
  44. #define dd_world_set_default(WORLD) dd_default_world_size = sizeof(struct WORLD); dd_default_world_constructor = WORLD ## _create;
  45. #endif