Tileset.h 849 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef INCLUDE_TILESET_H
  2. #define INCLUDE_TILESET_H
  3. #include <vector>
  4. #include <map>
  5. namespace WalrusRPG
  6. {
  7. struct Frame
  8. {
  9. unsigned frame;
  10. unsigned duration;
  11. };
  12. class Tileset
  13. {
  14. protected:
  15. const unsigned short *sheet;
  16. unsigned sheet_width;
  17. unsigned sheet_height;
  18. unsigned tile_width;
  19. unsigned tile_height;
  20. std::map<unsigned, std::vector<Frame>> animations;
  21. public:
  22. Tileset(unsigned short *sheet, unsigned sheet_width, unsigned sheet_height, unsigned tile_width, unsigned tile_heihgt);
  23. void add_animation(int index, std::vector<WalrusRPG::Frame> anim);
  24. void render_tile(unsigned int index, unsigned x, unsigned y) const;
  25. void render_tile(unsigned int index, unsigned x, unsigned y, unsigned time) const;
  26. };
  27. }
  28. #endif