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 525B

1234567891011121314151617181920212223242526272829303132
  1. #pragma once
  2. #include "common.h"
  3. #include "Resource.h"
  4. #include "Clock.h"
  5. #include "Resource.h"
  6. namespace Swan {
  7. class Animation {
  8. public:
  9. enum class Flags {
  10. HFLIP = 1,
  11. };
  12. Animation(ImageResource &resource, float interval, Flags flags = (Flags)0):
  13. resource_(resource), interval_(interval), timer_(interval), flags_(flags) {}
  14. void tick(float dt);
  15. void draw(Win &win);
  16. void reset();
  17. private:
  18. ImageResource &resource_;
  19. float interval_;
  20. float timer_;
  21. Flags flags_;
  22. int frame_ = 0;
  23. bool dirty_ = true;
  24. };
  25. }