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

123456789101112131415161718192021222324252627282930313233343536373839
  1. #pragma once
  2. #include <SFML/Graphics/Sprite.hpp>
  3. #include "common.h"
  4. #include "Asset.h"
  5. namespace Swan {
  6. class Animation {
  7. public:
  8. enum class Flags {
  9. HFLIP = 1,
  10. };
  11. Animation() = default;
  12. Animation(int w, int h, double interval, const Asset &asset, int flags = 0) {
  13. init(w, h, interval, asset, flags);
  14. }
  15. void init(int w, int h, double interval, const Asset &asset, int flags = 0);
  16. void tick(double dt);
  17. void draw(Win &win);
  18. void reset();
  19. int width_, height_;
  20. private:
  21. double interval_;
  22. const Asset *asset_;
  23. int fcount_;
  24. int frame_ = 0;
  25. bool dirty_ = true;
  26. double time_ = 0;
  27. sf::Sprite sprite_;
  28. };
  29. }