Open Source Tomb Raider Engine
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Sprite.h 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*!
  2. * \file include/Sprite.h
  3. * \brief World Sprite
  4. *
  5. * \author xythobuz
  6. */
  7. #ifndef _SPRITE_H_
  8. #define _SPRITE_H_
  9. #include <cstdint>
  10. #include "loader/Loader.h"
  11. #include "TombRaider.h"
  12. class Sprite {
  13. public:
  14. Sprite(uint16_t tile, uint8_t x, uint8_t y, uint16_t width, uint16_t height);
  15. Sprite(TombRaider& tr, unsigned int room, unsigned int index);
  16. Sprite(TombRaider& tr, unsigned int item, unsigned int sequence, unsigned int index) :
  17. Sprite((tr.Sprite() + ((tr.SpriteSequence() + sequence)->offset) + index)->tile,
  18. (tr.Sprite() + ((tr.SpriteSequence() + sequence)->offset) + index)->x,
  19. (tr.Sprite() + ((tr.SpriteSequence() + sequence)->offset) + index)->y,
  20. (tr.Sprite() + ((tr.SpriteSequence() + sequence)->offset) + index)->width,
  21. (tr.Sprite() + ((tr.SpriteSequence() + sequence)->offset) + index)->height) { }
  22. void display();
  23. void display(float x, float y, float w, float h);
  24. private:
  25. float vertex[4][3];
  26. float texel[4][2];
  27. //float pos[3];
  28. //float radius; //!< \fixme yeah, I know (I don't? --xythobuz)
  29. int texture;
  30. };
  31. class SpriteSequence {
  32. public:
  33. SpriteSequence(int32_t objectID);
  34. void add(Sprite s);
  35. SpriteSequence(TombRaider& tr, unsigned int item, unsigned int sequence);
  36. ~SpriteSequence();
  37. unsigned long size();
  38. Sprite& get(unsigned long index);
  39. private:
  40. int32_t id;
  41. std::vector<Sprite> sprites;
  42. std::vector<Sprite*> oldsprites;
  43. };
  44. #endif