]> git.localhorst.tv Git - l2e.git/blobdiff - src/main.cpp
added melee animation of monsters
[l2e.git] / src / main.cpp
index 841dc616f35cee60c181ee43324b29f197942ac1..14a6336f014df0d2028d3124f2699ca9a2af64b1 100644 (file)
@@ -12,6 +12,7 @@
 #include "battle/Monster.h"
 #include "battle/PartyLayout.h"
 #include "battle/Resources.h"
+#include "battle/Stats.h"
 #include "common/Ikari.h"
 #include "common/Inventory.h"
 #include "common/Item.h"
@@ -40,6 +41,7 @@ using battle::BattleState;
 using battle::Hero;
 using battle::Monster;
 using battle::PartyLayout;
+using battle::Stats;
 using common::Ikari;
 using common::Inventory;
 using common::Item;
@@ -87,12 +89,24 @@ int main(int argc, char **argv) {
                heroesLayout.AddPosition(Point<Uint8>(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("Monster");
-               monster.SetSprite(&dummySprite);
-               monster.SetMaxHealth(10);
-               monster.SetHealth(10);
+               monster.SetName("Lizard");
+               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, 4 * framerate);
+               monsterAttackAnimation.AddFrame(0, 1, Vector<int>(16, 0));
+               monsterAttackAnimation.AddFrame(0, 0, Vector<int>(16, 0));
+               monsterAttackAnimation.AddFrame(0, 1, Vector<int>(16, 0));
+               monster.SetAttackAnimation(&monsterAttackAnimation);
+               SDL_Surface *monsterMeleeImg(IMG_Load("test-data/attack-monster.png"));
+               Sprite monsterMeleeSprite(monsterMeleeImg, 96, 64);
+               SimpleAnimation monsterMeleeAnimation(&monsterMeleeSprite, framerate, 14);
+               monster.SetMeleeAnimation(&monsterMeleeAnimation);
 
                SDL_Surface *maximImg(IMG_Load("test-data/maxim.png"));
                Sprite maximSprite(maximImg, 64, 64);
@@ -105,6 +119,7 @@ int main(int argc, char **argv) {
                maxim.SetMaxMana(20);
                maxim.SetMana(20);
                maxim.SetIP(0);
+               maxim.SetStats(Stats(28, 22, 28, 17, 14, 100, 10));
                ComplexAnimation maximAttackAnimation(&maximSprite, framerate);
                // TODO: cross check double frames; could be related to differences in framerates
                maximAttackAnimation.AddFrames(1, 0, Vector<int>(0,  0), 7); // TODO: maybe this could also be a pause before the battle animation
@@ -137,7 +152,8 @@ int main(int argc, char **argv) {
                selan.SetHealth(28);
                selan.SetMaxMana(23);
                selan.SetMana(23);
-               selan.SetIP(1);
+               selan.SetIP(0);
+               selan.SetStats(Stats(23, 21, 23, 19, 22, 80, 13));
                ComplexAnimation selanAttackAnimation(&selanSprite, framerate);
                selanAttackAnimation.AddFrames(1, 0, Vector<int>(4, 0), 2);
                selanAttackAnimation.AddFrame(1, 0, Vector<int>(8, 2));
@@ -171,7 +187,8 @@ int main(int argc, char **argv) {
                guy.SetHealth(38);
                guy.SetMaxMana(0);
                guy.SetMana(0);
-               guy.SetIP(254);
+               guy.SetIP(0);
+               guy.SetStats(Stats(38, 25, 38, 13, 8, 90, 8));
                ComplexAnimation guyAttackAnimation(&guySprite, framerate);
                guyAttackAnimation.AddFrames(1, 0, Vector<int>(-4, 0), 2);
                guyAttackAnimation.AddFrames(1, 0, Vector<int>(-8, 0), 2);
@@ -199,7 +216,8 @@ int main(int argc, char **argv) {
                dekar.SetHealth(38);
                dekar.SetMaxMana(0);
                dekar.SetMana(0);
-               dekar.SetIP(255);
+               dekar.SetIP(0);
+               dekar.SetStats(Stats(46, 29, 46, 13, 7, 100, 5));
                ComplexAnimation dekarAttackAnimation(&dekarSprite, framerate);
                dekarAttackAnimation.AddFrame(1, 0, Vector<int>(4, 0));
                dekarAttackAnimation.AddFrame(1, 0, Vector<int>(8, 2));