Tileset.h 774 B

12345678910111213141516171819202122232425262728293031
  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 render_tile(unsigned int index, unsigned x, unsigned y) const;
  24. void render_tile(unsigned int index, unsigned x, unsigned y, unsigned time) const;
  25. };
  26. }
  27. #endif