A 2D tile-based sandbox game.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Animation.h 529B

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. #include <SDL2/SDL.h>
  3. #include "common.h"
  4. #include "Resource.h"
  5. #include "Clock.h"
  6. #include "Resource.h"
  7. namespace Swan {
  8. class Animation {
  9. public:
  10. Animation(ImageResource &resource, float interval, SDL_RendererFlip flip = SDL_FLIP_NONE):
  11. resource_(resource), interval_(interval), timer_(interval), flip_(flip) {}
  12. void tick(float dt);
  13. void draw(const Vec2 &pos, Win &win);
  14. void reset();
  15. private:
  16. ImageResource &resource_;
  17. float interval_;
  18. float timer_;
  19. SDL_RendererFlip flip_;
  20. int frame_ = 0;
  21. };
  22. }