spritelayout.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef spritelayout_H_INCLUDED
  2. #define spritelayout_H_INCLUDED
  3. /* The layout of the sprite. Each int * pointer field should be ponted to
  4. * an array of size rows.
  5. * In general, the cells of a sprite are expected to be layed out on a sprite
  6. * sheet in rows of equal height, and in columns of equal width.
  7. */
  8. struct SpriteLayout_ {
  9. int rows;
  10. int * per_row;
  11. int * row_type;
  12. int * row_dir;
  13. double * row_duration;
  14. /* The maximum sizes of the individual frames or layers. */
  15. int size_x;
  16. int size_y;
  17. /* If not negative, this means the standinwaltk'th frame of the
  18. walking animation is in fact the standing position. This frame should be skipped
  19. for walking and added to a separate standing position.
  20. The standing actions will be placed after all other actions of the sprite.
  21. */
  22. int standinwalk;
  23. /* The offset from the top to the "feet" of the sprite. Must be the same for
  24. * all frames. */
  25. int offset_x;
  26. int offset_y;
  27. };
  28. #define DEFINE_SPRITELAYOUT(NAME, ROWS, PER_ROW, ROW_POSE, ROW_DIR, \
  29. SIZE_X, SIZE_Y, STANDINWALK, OFFSET_X, OFFSET_Y) \
  30. struct SpriteLayout_ NAME = { ROWS , PER_ROW, ROW_POSE, ROW_DIR, \
  31. SIZE_X, SIZE_Y, STANDINWALK, OFFSET_X, OFFSET_Y }
  32. int spritelayout_rows(SpriteLayout * layout);
  33. Sprite * spritelayout_loadactionlayer(SpriteLayout * layout, Sprite * sprite,
  34. Image * source, int actionindex, int layerindex);
  35. SpriteLayout * spritelayout_for(int load_type);
  36. Sprite * spritelayout_load_layer
  37. (SpriteLayout * layout, Sprite * sprite, Image * source, int layeri);
  38. #endif