From abede3a0c94a057bc70305a1a858363a2a686f7e Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Sun, 12 Aug 2012 18:07:07 +0200 Subject: [PATCH] added offsetabiliy to animations --- src/graphics/Animation.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/graphics/Animation.h b/src/graphics/Animation.h index 55a16d9..0f33541 100644 --- a/src/graphics/Animation.h +++ b/src/graphics/Animation.h @@ -24,9 +24,9 @@ class Animation { public: Animation() - : sprite(0), frameTime(0), repeat(false) { } + : sprite(0), frameTime(0), colOffset(0), rowOffset(0), repeat(false) { } Animation(const Sprite *sprite, int frameTime, bool repeat = false) - : sprite(sprite), frameTime(frameTime), repeat(repeat) { } + : sprite(sprite), frameTime(frameTime), colOffset(0), rowOffset(0), repeat(repeat) { } virtual ~Animation() { }; public: @@ -42,8 +42,14 @@ public: bool Running() const { return timer.Running() && (repeat || timer.Iteration() < NumFrames()); } + + void SetColOffset(int offset) { colOffset = offset; } + int ColOffset() const { return colOffset; } + void SetRowOffset(int offset) { rowOffset = offset; } + int RowOffset() const { return rowOffset; } + virtual void Draw(SDL_Surface *dest, geometry::Point position) const { - sprite->Draw(dest, position, Col(), Row()); + sprite->Draw(dest, position, Col() + ColOffset(), Row() + RowOffset()); } void DrawTopRight(SDL_Surface *dest, geometry::Point position) const { geometry::Vector offset(-sprite->Width(), 0); @@ -68,6 +74,8 @@ private: const Sprite *sprite; app::Timer timer; int frameTime; + int colOffset; + int rowOffset; bool repeat; }; -- 2.39.2