]> git.localhorst.tv Git - l2e.git/commitdiff
renamed Animation to SimpleAnimation
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 11 Aug 2012 22:04:36 +0000 (00:04 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 11 Aug 2012 22:13:07 +0000 (00:13 +0200)
src/battle/BattleState.h
src/battle/states/PerformAttacks.cpp
src/graphics/Animation.h [deleted file]
src/graphics/SimpleAnimation.h [new file with mode: 0644]

index 736e2c17ad3f15dbf733220728b53fce1df6a5c8..77e2b5dbdfa214db81bcd6a8f1313b18e05ce49f 100644 (file)
@@ -19,8 +19,8 @@
 #include "../app/State.h"
 #include "../geometry/Point.h"
 #include "../geometry/Vector.h"
-#include "../graphics/Animation.h"
 #include "../graphics/Menu.h"
+#include "../graphics/SimpleAnimation.h"
 
 #include <vector>
 #include <SDL.h>
@@ -97,8 +97,8 @@ public:
        Monster &MonsterAt(int index) { return monsters[index]; }
        const Monster &MonsterAt(int index) const { return monsters[index]; }
 
-       graphics::Animation &HeroAnimationAt(int index) { return heroAnimations[index]; }
-       const graphics::Animation &HeroAnimationAt(int index) const { return heroAnimations[index]; }
+       graphics::SimpleAnimation &HeroAnimationAt(int index) { return heroAnimations[index]; }
+       const graphics::SimpleAnimation &HeroAnimationAt(int index) const { return heroAnimations[index]; }
 
        const HeroTag &HeroTagAt(int index) const { return heroTags[index]; }
        const geometry::Point<int> &HeroTagPositionAt(int index) const { return heroTagPositions[index]; }
@@ -153,7 +153,7 @@ private:
        std::vector<geometry::Point<int> > heroesPositions;
        std::vector<Monster> monsters;
        Hero heroes[4];
-       graphics::Animation heroAnimations[4];
+       graphics::SimpleAnimation heroAnimations[4];
        graphics::Menu<const common::Spell *> spellMenus[4];
        graphics::Menu<const common::Item *> itemMenu;
        graphics::Menu<const common::Item *> ikariMenus[4];
index 09366d4d3ec3b642e1002eb13522fa82bc590553..c34e1144cdc6e4e54de9ca9ec1b6130bb6dafbd6 100644 (file)
@@ -17,9 +17,9 @@
 #include "../../common/Spell.h"
 #include "../../geometry/operators.h"
 #include "../../geometry/Point.h"
-#include "../../graphics/Animation.h"
 #include "../../graphics/Font.h"
 #include "../../graphics/Frame.h"
+#include "../../graphics/SimpleAnimation.h"
 
 #include <cstring>
 
@@ -27,7 +27,7 @@ using app::Application;
 using app::Input;
 using geometry::Point;
 using geometry::Vector;
-using graphics::Animation;
+using graphics::SimpleAnimation;
 
 namespace battle {
 
@@ -80,13 +80,13 @@ void PerformAttacks::HandleEvents(const Input &input) {
 
                                switch (ac.GetType()) {
                                        case AttackChoice::SWORD:
-                                               battle->HeroAnimationAt(cursor) = Animation(
+                                               battle->HeroAnimationAt(cursor) = SimpleAnimation(
                                                                battle->HeroAt(cursor).Sprite(),
                                                                battle->HeroAt(cursor).AttackFrameTime(),
                                                                battle->HeroAt(cursor).AttackFrames(), 2);
                                                break;
                                        case AttackChoice::MAGIC:
-                                               battle->HeroAnimationAt(cursor) = Animation(
+                                               battle->HeroAnimationAt(cursor) = SimpleAnimation(
                                                                battle->HeroAt(cursor).Sprite(),
                                                                battle->HeroAt(cursor).SpellFrameTime(),
                                                                battle->HeroAt(cursor).SpellFrames(), 3);
@@ -96,12 +96,12 @@ void PerformAttacks::HandleEvents(const Input &input) {
                                        case AttackChoice::IKARI:
                                                if (ac.GetItem()->HasIkari()) {
                                                        if (ac.GetItem()->GetIkari()->IsMagical()) {
-                                                               battle->HeroAnimationAt(cursor) = Animation(
+                                                               battle->HeroAnimationAt(cursor) = SimpleAnimation(
                                                                                battle->HeroAt(cursor).Sprite(),
                                                                                battle->HeroAt(cursor).SpellFrameTime(),
                                                                                battle->HeroAt(cursor).SpellFrames(), 3);
                                                        } else {
-                                                               battle->HeroAnimationAt(cursor) = Animation(
+                                                               battle->HeroAnimationAt(cursor) = SimpleAnimation(
                                                                                battle->HeroAt(cursor).Sprite(),
                                                                                battle->HeroAt(cursor).AttackFrameTime(),
                                                                                battle->HeroAt(cursor).AttackFrames(), 2);
diff --git a/src/graphics/Animation.h b/src/graphics/Animation.h
deleted file mode 100644 (file)
index 146184c..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Animation.h
- *
- *  Created on: Aug 11, 2012
- *      Author: holy
- */
-
-#ifndef GRAPHICS_ANIMATION_H_
-#define GRAPHICS_ANIMATION_H_
-
-#include "Sprite.h"
-#include "../app/Application.h"
-#include "../app/State.h"
-#include "../app/Timer.h"
-#include "../geometry/Point.h"
-
-#include <SDL.h>
-
-namespace graphics {
-
-class Animation {
-
-public:
-       Animation()
-       : sprite(0), frameTime(0), numFrames(0), col(0), row(0), repeat(false) { }
-       Animation(const Sprite *sprite, int frameTime, int numFrames, int col = 0, int row = 0, bool repeat = false)
-       : sprite(sprite), frameTime(frameTime), numFrames(numFrames), col(col), row(row), repeat(repeat) { }
-
-public:
-       void Start(app::State &ctrl) {
-               timer = ctrl.GraphicsTimers().StartInterval(frameTime);
-       }
-       void Start(app::Application &ctrl) {
-               timer = ctrl.GlobalTimers().StartInterval(frameTime);
-       }
-       void Stop() {
-               timer = app::Timer<Uint32>();
-       }
-       bool Running() const {
-               return timer.Running() && (repeat || timer.Iteration() < numFrames);
-       }
-       void Draw(SDL_Surface *dest, geometry::Point<int> position) {
-               sprite->Draw(dest, position, col, Running() ? row + (timer.Iteration() % numFrames) : row);
-       }
-       void DrawCenterBottom(SDL_Surface *dest, geometry::Point<int> position) const {
-               sprite->DrawCenterBottom(dest, position, col, Running() ? row + (timer.Iteration() % numFrames) : row);
-       }
-
-private:
-       const Sprite *sprite;
-       app::Timer<Uint32> timer;
-       int frameTime;
-       int numFrames;
-       int col;
-       int row;
-       bool repeat;
-
-};
-
-}
-
-#endif /* GRAPHICS_ANIMATION_H_ */
diff --git a/src/graphics/SimpleAnimation.h b/src/graphics/SimpleAnimation.h
new file mode 100644 (file)
index 0000000..dffd863
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ *  SimpleAnimation.h
+ *
+ *  Created on: Aug 11, 2012
+ *      Author: holy
+ */
+
+#ifndef GRAPHICS_SIMPLEANIMATION_H_
+#define GRAPHICS_SIMPLEANIMATION_H_
+
+#include "Sprite.h"
+#include "../app/Application.h"
+#include "../app/State.h"
+#include "../app/Timer.h"
+#include "../geometry/Point.h"
+
+#include <SDL.h>
+
+namespace graphics {
+
+class SimpleAnimation {
+
+public:
+       SimpleAnimation()
+       : sprite(0), frameTime(0), numFrames(0), col(0), row(0), repeat(false) { }
+       SimpleAnimation(const Sprite *sprite, int frameTime, int numFrames, int col = 0, int row = 0, bool repeat = false)
+       : sprite(sprite), frameTime(frameTime), numFrames(numFrames), col(col), row(row), repeat(repeat) { }
+
+public:
+       void Start(app::State &ctrl) {
+               timer = ctrl.GraphicsTimers().StartInterval(frameTime);
+       }
+       void Start(app::Application &ctrl) {
+               timer = ctrl.GlobalTimers().StartInterval(frameTime);
+       }
+       void Stop() {
+               timer = app::Timer<Uint32>();
+       }
+       bool Running() const {
+               return timer.Running() && (repeat || timer.Iteration() < numFrames);
+       }
+       void Draw(SDL_Surface *dest, geometry::Point<int> position) {
+               sprite->Draw(dest, position, col, Running() ? row + (timer.Iteration() % numFrames) : row);
+       }
+       void DrawCenterBottom(SDL_Surface *dest, geometry::Point<int> position) const {
+               sprite->DrawCenterBottom(dest, position, col, Running() ? row + (timer.Iteration() % numFrames) : row);
+       }
+
+private:
+       const Sprite *sprite;
+       app::Timer<Uint32> timer;
+       int frameTime;
+       int numFrames;
+       int col;
+       int row;
+       bool repeat;
+
+};
+
+}
+
+#endif /* GRAPHICS_SIMPLEANIMATION_H_ */