From: Daniel Karbach Date: Sun, 19 Aug 2012 19:51:56 +0000 (+0200) Subject: added monster's attack animation X-Git-Url: http://git.localhorst.tv/?a=commitdiff_plain;h=c6156f6b3dc88a97a78694a2652dfbc874fcc8e4;p=l2e.git added monster's attack animation --- diff --git a/src/battle/Monster.h b/src/battle/Monster.h index 50a1807..e4d787e 100644 --- a/src/battle/Monster.h +++ b/src/battle/Monster.h @@ -12,7 +12,11 @@ #include -namespace graphics { class Sprite; } +namespace common { class Item; } +namespace graphics { + class Animation; + class Sprite; +} namespace battle { @@ -42,12 +46,17 @@ public: Uint16 ExpReward() const { return expReward; } Uint16 GoldReward() const { return goldReward; } - const /* Item */ void *DropItem() const { return dropItem; } + const common::Item *DropItem() const { return dropItem; } Uint8 DropChance() const { return dropChance; } const /* Script */ void *AttackScript() { return attackScript; } const /* Script */ void *DefenseScript() { return defenseScript; } + graphics::Animation *AttackAnimation() { return attackAnimation; } + const graphics::Animation *AttackAnimation() const { return attackAnimation; } + graphics::Animation *SpellAnimation() { return spellAnimation; } + const graphics::Animation *SpellAnimation() const { return spellAnimation; } + // temporary setters until loader is implemented public: void SetName(const char *n) { name = n; } @@ -60,13 +69,19 @@ public: void SetStats(const Stats &s) { stats = s; } void SetReward(Uint16 exp, Uint16 gold) { expReward = exp; goldReward = gold; } + void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; } + void SetSpellAnimation(graphics::Animation *a) { spellAnimation = a; } + private: const char *name; graphics::Sprite *sprite; - /* Item */ void *dropItem; + common::Item *dropItem; /* Script */ void *attackScript; /* Script */ void *defenseScript; + graphics::Animation *attackAnimation; + graphics::Animation *spellAnimation; + Uint16 maxHealth, health; Uint16 maxMana, mana; diff --git a/src/main.cpp b/src/main.cpp index 987a985..1781e5f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -89,15 +89,20 @@ int main(int argc, char **argv) { heroesLayout.AddPosition(Point(160, 152)); SDL_Surface *monsterImg(IMG_Load("test-data/monster.png")); - Sprite dummySprite(monsterImg, 64, 64); + Sprite monsterSprite(monsterImg, 64, 64); Monster monster; monster.SetName("Lizard"); - monster.SetSprite(&dummySprite); + monster.SetSprite(&monsterSprite); monster.SetLevel(1); monster.SetMaxHealth(8); monster.SetHealth(8); monster.SetStats(Stats(14, 6, 6, 6, 6, 6, 6)); monster.SetReward(3, 5); + ComplexAnimation monsterAttackAnimation(&monsterSprite, 120); + monsterAttackAnimation.AddFrame(0, 1, Vector(16, 0)); + monsterAttackAnimation.AddFrame(0, 0, Vector(16, 0)); + monsterAttackAnimation.AddFrame(0, 1, Vector(16, 0)); + monster.SetAttackAnimation(&monsterAttackAnimation); SDL_Surface *maximImg(IMG_Load("test-data/maxim.png")); Sprite maximSprite(maximImg, 64, 64); diff --git a/test-data/monster.png b/test-data/monster.png index 9439102..0484303 100644 Binary files a/test-data/monster.png and b/test-data/monster.png differ