]> git.localhorst.tv Git - l2e.git/commitdiff
added sword attack animation
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 15 Aug 2012 20:22:33 +0000 (22:22 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 15 Aug 2012 20:22:33 +0000 (22:22 +0200)
src/battle/Hero.cpp
src/battle/Hero.h
src/battle/states/PerformAttacks.cpp
src/common/Item.cpp
src/common/Item.h
src/main.cpp
test-data/attack-sword.png [new file with mode: 0644]

index ff411137773ee72a21fa20ec54ba5115f3cdd914..4bfdf0a0cf651e879cb80d7b1bad92e12effd892 100644 (file)
@@ -20,6 +20,7 @@ Hero::Hero()
 , ring(0)
 , jewel(0)
 
+, meleeAnimation(0)
 , attackAnimation(0)
 , spellAnimation(0)
 
index e200838487a177cef24e2ea0b200d1a35a99867f..d5284ae3d9a9f78f5bf3661be526d73ad04d9c94 100644 (file)
@@ -55,6 +55,13 @@ public:
        Uint16 Gut() const { return gut; }
        Uint16 MagicResistance() const { return magicResistance; }
 
+       common::Item *Weapon() { return weapon; }
+       common::Item *Armor() { return armor; }
+       common::Item *Shield() { return shield; }
+       common::Item *Helmet() { return helmet; }
+       common::Item *Ring() { return ring; }
+       common::Item *Jewel() { return jewel; }
+
        const common::Item *Weapon() const { return weapon; }
        const common::Item *Armor() const { return armor; }
        const common::Item *Shield() const { return shield; }
@@ -88,12 +95,12 @@ public:
        void SetMana(Uint16 m) { mana = m; }
        void SetIP(Uint8 i) { ip = i; }
 
-       void SetWeapon(const common::Item *i) { weapon = i; }
-       void SetArmor(const common::Item *i) { armor = i; }
-       void SetShield(const common::Item *i) { shield = i; }
-       void SetHelmet(const common::Item *i) { helmet = i; }
-       void SetRing(const common::Item *i) { ring = i; }
-       void SetJewel(const common::Item *i) { jewel = i; }
+       void SetWeapon(common::Item *i) { weapon = i; }
+       void SetArmor(common::Item *i) { armor = i; }
+       void SetShield(common::Item *i) { shield = i; }
+       void SetHelmet(common::Item *i) { helmet = i; }
+       void SetRing(common::Item *i) { ring = i; }
+       void SetJewel(common::Item *i) { jewel = i; }
 
        void AddSpell(const common::Spell *s) { spells.push_back(s); }
 
@@ -105,12 +112,12 @@ private:
        const char *name;
        graphics::Sprite *sprite;
 
-       const common::Item *weapon;
-       const common::Item *armor;
-       const common::Item *shield;
-       const common::Item *helmet;
-       const common::Item *ring;
-       const common::Item *jewel;
+       common::Item *weapon;
+       common::Item *armor;
+       common::Item *shield;
+       common::Item *helmet;
+       common::Item *ring;
+       common::Item *jewel;
 
        graphics::Animation *meleeAnimation;
        graphics::Animation *attackAnimation;
index 498014a551d68b8fd81494989a8de44cc558a350..2a8f3a53b697a4aecb3e5270c4e7c65d4be69ff9 100644 (file)
@@ -79,11 +79,12 @@ void PerformAttacks::HandleEvents(const Input &input) {
                        case AttackChoice::SWORD:
                                if (hero.HasWeapon()) {
                                        titleBarText = hero.Weapon()->Name();
+                                       targetAnimation = hero.Weapon()->AttackAnimation();
                                } else {
                                        titleBarText = "Melee attack!";
+                                       targetAnimation = hero.MeleeAnimation();
                                }
                                moveAnimation = hero.AttackAnimation();
-                               targetAnimation = hero.MeleeAnimation();
 
                                numberAnimation.push_back(NumberAnimation(15, battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite));
                                if (ac.Selection().TargetsEnemies()) {
index be22c6e77e3d7697a42f3fbd6c0cebd7180768ef..f14fd22e7b4374f41bd7c481c4d04a96891f333f 100644 (file)
@@ -14,6 +14,7 @@ Item::Item()
 , menuIcon(0)
 , chestIcon(0)
 , ikari(0)
+, attackAnimation(0)
 
 , value(0)
 , properties(0)
index 6ae374b9e4244a3cc58edcf80482326992c21cd5..1d9d51c56baa8260779f6b3115d876bc8d4a964d 100644 (file)
 
 #include <SDL.h>
 
-namespace graphics { class Sprite; }
+namespace graphics {
+       class Animation;
+       class Sprite;
+}
 
 namespace common {
 
@@ -48,6 +51,9 @@ public:
        bool HasIkari() const { return ikari; }
        const Ikari *GetIkari() const { return ikari; }
 
+       graphics::Animation *AttackAnimation() { return attackAnimation; }
+       const graphics::Animation *AttackAnimation() const { return attackAnimation; }
+
        Uint16 Value() const { return value; }
 
        bool CanEquipWeapon() const { return equipable & EQUIPPABLE_WEAPON; }
@@ -80,6 +86,7 @@ public:
        void SetMenuIcon(const graphics::Sprite *icon) { menuIcon = icon; }
        void SetUsableInBattle() { usability |= USABILITY_BATTLE; }
        void SetIkari(const Ikari *i) { ikari = i; }
+       void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; }
 
 private:
        enum Usability {
@@ -125,6 +132,7 @@ private:
        const graphics::Sprite *menuIcon;
        const graphics::Sprite *chestIcon;
        const Ikari *ikari;
+       graphics::Animation *attackAnimation;
 
        Uint16 value;
        Uint16 properties;
index 49f0a1f2f5e363eb3fef8f2a13848bf4854219c0..49ef3366c581560750aa2155999d60fe300fcd17 100644 (file)
@@ -119,7 +119,7 @@ int main(int argc, char **argv) {
                maxim.SetSpellAnimation(&maximSpellAnimation);
                SDL_Surface *maximMeleeImg(IMG_Load("test-data/melee-maxim.png"));
                Sprite maximMeleeSprite(maximMeleeImg, 96, 96);
-               SimpleAnimation maximMeleeAnimation(&maximMeleeSprite, 30, 4);
+               SimpleAnimation maximMeleeAnimation(&maximMeleeSprite, 60, 4);
                maxim.SetMeleeAnimation(&maximMeleeAnimation);
 
                SDL_Surface *selanImg(IMG_Load("test-data/selan.png"));
@@ -153,7 +153,7 @@ int main(int argc, char **argv) {
                selan.SetSpellAnimation(&selanSpellAnimation);
                SDL_Surface *selanMeleeImg(IMG_Load("test-data/melee-selan.png"));
                Sprite selanMeleeSprite(selanMeleeImg, 96, 96);
-               SimpleAnimation selanMeleeAnimation(&selanMeleeSprite, 30, 4);
+               SimpleAnimation selanMeleeAnimation(&selanMeleeSprite, 60, 4);
                selan.SetMeleeAnimation(&selanMeleeAnimation);
 
                SDL_Surface *guyImg(IMG_Load("test-data/guy.png"));
@@ -181,7 +181,7 @@ int main(int argc, char **argv) {
                guy.SetAttackAnimation(&guyAttackAnimation);
                SDL_Surface *guyMeleeImg(IMG_Load("test-data/melee-guy.png"));
                Sprite guyMeleeSprite(guyMeleeImg, 96, 96);
-               SimpleAnimation guyMeleeAnimation(&guyMeleeSprite, 30, 4);
+               SimpleAnimation guyMeleeAnimation(&guyMeleeSprite, 60, 4);
                guy.SetMeleeAnimation(&guyMeleeAnimation);
 
                SDL_Surface *dekarImg(IMG_Load("test-data/dekar.png"));
@@ -213,7 +213,7 @@ int main(int argc, char **argv) {
                dekar.SetSpellAnimation(&dekarSpellAnimation);
                SDL_Surface *dekarMeleeImg(IMG_Load("test-data/melee-dekar.png"));
                Sprite dekarMeleeSprite(dekarMeleeImg, 96, 96);
-               SimpleAnimation dekarMeleeAnimation(&dekarMeleeSprite, 30, 4);
+               SimpleAnimation dekarMeleeAnimation(&dekarMeleeSprite, 60, 4);
                dekar.SetMeleeAnimation(&dekarMeleeAnimation);
 
                battle::Resources battleRes;
@@ -452,6 +452,10 @@ int main(int argc, char **argv) {
                battleRes.itemMenuHeadline = "Please choose an item.";
                battleRes.itemMenuPrototype = Menu<const common::Item *>(&normalFont, &disabledFont, &handCursorSprite, 15, 6, 8, 16, 1, 32, 2, ':');
 
+               SDL_Surface *swordAttackImg(IMG_Load("test-data/attack-sword.png"));
+               Sprite swordAttackSprite(swordAttackImg, 96, 96);
+               SimpleAnimation swordAttackAnimation(&swordAttackSprite, 60, 4);
+
                Item zircoSword;
                zircoSword.SetName("Zirco sword");
                zircoSword.SetMenuIcon(&swordIcon);
@@ -461,7 +465,8 @@ int main(int argc, char **argv) {
                firestorm.GetTargetingMode().TargetAllEnemies();
                firestorm.SetPhysical();
                zircoSword.SetIkari(&firestorm);
-//             maxim.SetWeapon(&zircoSword);
+               zircoSword.SetAttackAnimation(&swordAttackAnimation);
+               maxim.SetWeapon(&zircoSword);
                Item zirconArmor;
                zirconArmor.SetName("Zircon armor");
                zirconArmor.SetMenuIcon(&armorIcon);
@@ -522,7 +527,7 @@ int main(int argc, char **argv) {
                thundershriek.GetTargetingMode().TargetAllEnemies();
                thundershriek.SetPhysical();
                zircoWhip.SetIkari(&thundershriek);
-               selan.SetWeapon(&zircoWhip);
+//             selan.SetWeapon(&zircoWhip);
                Item zirconPlate;
                zirconPlate.SetName("Zircon plate");
                zirconPlate.SetMenuIcon(&armorIcon);
@@ -583,7 +588,7 @@ int main(int argc, char **argv) {
                torrent.GetTargetingMode().TargetAllEnemies();
                torrent.SetPhysical();
                zircoAx.SetIkari(&torrent);
-               guy.SetWeapon(&zircoAx);
+//             guy.SetWeapon(&zircoAx);
                guy.SetArmor(&zirconArmor);
                Item megaShield;
                megaShield.SetName("Mega shield");
@@ -627,7 +632,7 @@ int main(int argc, char **argv) {
                dragonRush.GetTargetingMode().TargetSingleEnemy();
                dragonRush.SetPhysical();
                lizardBlow.SetIkari(&dragonRush);
-               dekar.SetWeapon(&lizardBlow);
+//             dekar.SetWeapon(&lizardBlow);
                Item holyRobe;
                holyRobe.SetName("Holy robe");
                holyRobe.SetMenuIcon(&armorIcon);
diff --git a/test-data/attack-sword.png b/test-data/attack-sword.png
new file mode 100644 (file)
index 0000000..82fe946
Binary files /dev/null and b/test-data/attack-sword.png differ