public:
const Sprite *GetSprite() const { return sprite; }
- void ChangeSprite(const Sprite *s) { sprite = s; }
int FrameTime() const { return frameTime; }
bool Repeat() const { return repeat; }
public:
explicit AnimationRunner(const Animation *a = 0, int colOffset = 0, int rowOffset = 0)
- : animation(a), colOffset(colOffset), rowOffset(rowOffset) { }
+ : animation(a), sprite(a ? a->GetSprite() : 0), colOffset(colOffset), rowOffset(rowOffset) { }
public:
bool Valid() const { return animation; }
void SetRowOffset(int offset) { rowOffset = offset; }
int RowOffset() const { return rowOffset; }
+ void ChangeSprite(const Sprite *s) { sprite = s; }
+ const Sprite *GetSprite() const { return sprite; }
+
void Draw(SDL_Surface *dest, geometry::Point<int> position) const {
- animation->GetSprite()->Draw(dest, position + animation->Offset(Frame()), animation->Col(Frame()) + ColOffset(), animation->Row(Frame()) + RowOffset());
+ sprite->Draw(dest, position + animation->Offset(Frame()), animation->Col(Frame()) + ColOffset(), animation->Row(Frame()) + RowOffset());
}
void DrawTopRight(SDL_Surface *dest, geometry::Point<int> position) const {
- geometry::Vector<int> offset(-animation->GetSprite()->Width(), 0);
+ geometry::Vector<int> offset(-sprite->Width(), 0);
Draw(dest, position + offset);
}
void DrawCenter(SDL_Surface *dest, geometry::Point<int> position) const {
- geometry::Vector<int> offset(-animation->GetSprite()->Width() / 2, -animation->GetSprite()->Height() / 2);
+ geometry::Vector<int> offset(-sprite->Width() / 2, -sprite->Height() / 2);
Draw(dest, position + offset);
}
void DrawCenterBottom(SDL_Surface *dest, geometry::Point<int> position) const {
- geometry::Vector<int> offset(-animation->GetSprite()->Width() / 2, -animation->GetSprite()->Height());
+ geometry::Vector<int> offset(-sprite->Width() / 2, -sprite->Height());
Draw(dest, position + offset);
}
private:
const Animation *animation;
+ const graphics::Sprite *sprite;
app::Timer<Uint32> timer;
int colOffset;
int rowOffset;