Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include <Siv3D.hpp>
- class Anime
- {
- public:
- Anime(const Texture& texture, int size, int frame) :
- m_texture(texture),
- m_size(size),
- m_frame(frame),
- m_index(0),
- m_count(0) {}
- void update()
- {
- ++m_count;
- if (m_count > m_frame)
- {
- m_count = 0;
- ++m_index;
- if (m_index >= m_size)
- {
- m_index = 0;
- }
- }
- }
- void draw(const Vec2& pos) const
- {
- m_texture.uv(static_cast<double>(m_index) / m_size, 0.0, 1.0 / m_size, 1.0).draw(pos);
- }
- private:
- Texture m_texture;
- int m_size;
- int m_frame;
- int m_index;
- int m_count;
- };
- void Main()
- {
- Texture texture(L"AsachunAnime.png");
- Anime anime(texture, 4, 10);
- while (System::Update())
- {
- anime.update();
- anime.draw(Mouse::Pos());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement