From: Daniel Karbach Date: Wed, 15 Aug 2012 20:22:33 +0000 (+0200) Subject: added sword attack animation X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;ds=sidebyside;h=c0068263474818f39e704eee12f753c0419f7708;hp=e79073197647340d84eafc4b750b54e1cb4e3c8f;p=l2e.git added sword attack animation --- diff --git a/src/battle/Hero.cpp b/src/battle/Hero.cpp index ff41113..4bfdf0a 100644 --- a/src/battle/Hero.cpp +++ b/src/battle/Hero.cpp @@ -20,6 +20,7 @@ Hero::Hero() , ring(0) , jewel(0) +, meleeAnimation(0) , attackAnimation(0) , spellAnimation(0) diff --git a/src/battle/Hero.h b/src/battle/Hero.h index e200838..d5284ae 100644 --- a/src/battle/Hero.h +++ b/src/battle/Hero.h @@ -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; diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index 498014a..2a8f3a5 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -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()) { diff --git a/src/common/Item.cpp b/src/common/Item.cpp index be22c6e..f14fd22 100644 --- a/src/common/Item.cpp +++ b/src/common/Item.cpp @@ -14,6 +14,7 @@ Item::Item() , menuIcon(0) , chestIcon(0) , ikari(0) +, attackAnimation(0) , value(0) , properties(0) diff --git a/src/common/Item.h b/src/common/Item.h index 6ae374b..1d9d51c 100644 --- a/src/common/Item.h +++ b/src/common/Item.h @@ -13,7 +13,10 @@ #include -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; diff --git a/src/main.cpp b/src/main.cpp index 49f0a1f..49ef336 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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(&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 index 0000000..82fe946 Binary files /dev/null and b/test-data/attack-sword.png differ