Advertisement
Guest User

Untitled

a guest
May 26th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. # include <Siv3D.hpp>
  2.  
  3. class Anime
  4. {
  5. public:
  6. Anime(const Texture& texture, int size, int frame) :
  7. m_texture(texture),
  8. m_size(size),
  9. m_frame(frame),
  10. m_index(0),
  11. m_count(0) {}
  12.  
  13. void update()
  14. {
  15. ++m_count;
  16.  
  17. if (m_count > m_frame)
  18. {
  19. m_count = 0;
  20. ++m_index;
  21.  
  22. if (m_index >= m_size)
  23. {
  24. m_index = 0;
  25. }
  26. }
  27. }
  28.  
  29. void draw(const Vec2& pos) const
  30. {
  31. m_texture.uv(static_cast<double>(m_index) / m_size, 0.0, 1.0 / m_size, 1.0).draw(pos);
  32. }
  33.  
  34. private:
  35. Texture m_texture;
  36. int m_size;
  37. int m_frame;
  38. int m_index;
  39. int m_count;
  40. };
  41.  
  42. void Main()
  43. {
  44. Texture texture(L"AsachunAnime.png");
  45.  
  46. Anime anime(texture, 4, 10);
  47.  
  48. while (System::Update())
  49. {
  50. anime.update();
  51. anime.draw(Mouse::Pos());
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement