A 2D tile-based sandbox game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Animation.h 507B

12345678910111213141516171819202122232425262728
  1. #pragma once
  2. #include <SDL.h>
  3. #include <cygnet/Renderer.h>
  4. #include "common.h"
  5. #include "Clock.h"
  6. namespace Swan {
  7. class Animation {
  8. public:
  9. Animation(Cygnet::RenderSprite sprite, float interval, Cygnet::Mat3gf mat = {}):
  10. sprite_(sprite), interval_(interval), timer_(interval), mat_(mat) {}
  11. void tick(float dt);
  12. void draw(const Vec2 &pos, Cygnet::Renderer &rnd);
  13. void reset();
  14. private:
  15. Cygnet::RenderSprite sprite_;
  16. float interval_;
  17. float timer_;
  18. Cygnet::Mat3gf mat_;
  19. int frame_ = 0;
  20. };
  21. }