Tileset.h 863 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef INCLUDE_TILESET_H
  2. #define INCLUDE_TILESET_H
  3. #include <TINYSTL/vector.h>
  4. #include <TINYSTL/unordered_map.h>
  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 tile_width;
  17. unsigned tile_height;
  18. tinystl::unordered_map<unsigned, tinystl::vector<Frame>> animations;
  19. public:
  20. Tileset(unsigned short *sheet, unsigned tile_width, unsigned tile_heihgt);
  21. void add_animation(int index, tinystl::vector<WalrusRPG::Frame> anim);
  22. void render_tile(unsigned int index, unsigned x, unsigned y) const;
  23. void render_tile(unsigned int index, unsigned x, unsigned y, unsigned time);
  24. int get_tile_width() const;
  25. int get_tile_height() const;
  26. };
  27. }
  28. #endif