#pragma once #include "sprite.h" struct Animation : public Sprite { explicit Animation( SDL_Renderer* renderer, const std::string& filename, const int width, const double durationS, const bool repeat ); ~Animation() override = default; public: /*! * \brief animation_ended - is the animation sequence ended as specified * timestamp? * \param timestamp * \return true if ended, false otherwise */ bool animation_ended(const TimeStamp timestamp) const; /*! * \brief frame - compute the frame number at current time for the the * animation started at timestamp * \param timestamp * \return frame number */ int frame(const TimeStamp timestamp) const; /*! * \brief rect - choose the right frame from the texture * \param timestamp * \return frame rect */ SDL_Rect rect(const TimeStamp timestamp) const; /*! * \brief durationS - durationS of the animation sequence in seconds */ const double durationS{1.}; const bool repeat{false}; // should we repeat the animation? };