]> git.localhorst.tv Git - l2e.git/commitdiff
revised Maxim's attack animation
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 15 Aug 2012 21:16:12 +0000 (23:16 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 15 Aug 2012 21:16:12 +0000 (23:16 +0200)
src/main.cpp

index 49ef3366c581560750aa2155999d60fe300fcd17..841dc616f35cee60c181ee43324b29f197942ac1 100644 (file)
@@ -66,6 +66,8 @@ int main(int argc, char **argv) {
        const int width = 800;
        const int height = 480;
 
+       const int framerate = 33;
+
        try {
                InitSDL sdl;
                InitImage image(IMG_INIT_PNG);
@@ -103,23 +105,26 @@ int main(int argc, char **argv) {
                maxim.SetMaxMana(20);
                maxim.SetMana(20);
                maxim.SetIP(0);
-               ComplexAnimation maximAttackAnimation(&maximSprite, 30);
-               maximAttackAnimation.AddFrame(1, 0, Vector<int>(2, 0));
-               maximAttackAnimation.AddFrame(1, 0, Vector<int>(2, -1));
-               maximAttackAnimation.AddFrames(2, 0, Vector<int>(2, -2), 2);
-               maximAttackAnimation.AddFrame(2, 0, Vector<int>(4, -2));
-               maximAttackAnimation.AddFrame(2, 0, Vector<int>(3, -1));
+               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
+               maximAttackAnimation.AddFrames(1, 0, Vector<int>(4, -1), 2);
+               maximAttackAnimation.AddFrames(2, 0, Vector<int>(4, -2), 2);
+               maximAttackAnimation.AddFrames(2, 0, Vector<int>(6, -2), 2);
+               maximAttackAnimation.AddFrames(2, 1, Vector<int>(6, -1), 1);
                maximAttackAnimation.AddFrames(2, 1, Vector<int>(3, -1), 2);
-               maximAttackAnimation.AddFrame(2, 1);
-               maximAttackAnimation.AddFrames(2, 2, Vector<int>(), 2);
+               maximAttackAnimation.AddFrames(2, 1, Vector<int>(0,  0), 1);
+               maximAttackAnimation.AddFrames(2, 2, Vector<int>(0,  0), 2);
+               maximAttackAnimation.AddFrames(2, 2, Vector<int>(2,  0), 1);
+               maximAttackAnimation.AddFrames(1, 0, Vector<int>(0,  0), 7); // TODO: maybe this could also be a pause between two animations
                maxim.SetAttackAnimation(&maximAttackAnimation);
-               ComplexAnimation maximSpellAnimation(&maximSprite, 150);
+               ComplexAnimation maximSpellAnimation(&maximSprite, 5 * framerate);
                maximSpellAnimation.AddFrames(3, 0, Vector<int>(), 2);
                maximSpellAnimation.AddFrame(3, 1);
                maxim.SetSpellAnimation(&maximSpellAnimation);
                SDL_Surface *maximMeleeImg(IMG_Load("test-data/melee-maxim.png"));
                Sprite maximMeleeSprite(maximMeleeImg, 96, 96);
-               SimpleAnimation maximMeleeAnimation(&maximMeleeSprite, 60, 4);
+               SimpleAnimation maximMeleeAnimation(&maximMeleeSprite, 2 * framerate, 4);
                maxim.SetMeleeAnimation(&maximMeleeAnimation);
 
                SDL_Surface *selanImg(IMG_Load("test-data/selan.png"));
@@ -133,7 +138,7 @@ int main(int argc, char **argv) {
                selan.SetMaxMana(23);
                selan.SetMana(23);
                selan.SetIP(1);
-               ComplexAnimation selanAttackAnimation(&selanSprite, 30);
+               ComplexAnimation selanAttackAnimation(&selanSprite, framerate);
                selanAttackAnimation.AddFrames(1, 0, Vector<int>(4, 0), 2);
                selanAttackAnimation.AddFrame(1, 0, Vector<int>(8, 2));
                selanAttackAnimation.AddFrame(2, 0, Vector<int>(10, 4));
@@ -145,7 +150,7 @@ int main(int argc, char **argv) {
                selanAttackAnimation.AddFrame(2, 2, Vector<int>(-8, -8));
                selanAttackAnimation.AddFrame(2, 2);
                selan.SetAttackAnimation(&selanAttackAnimation);
-               ComplexAnimation selanSpellAnimation(&selanSprite, 30);
+               ComplexAnimation selanSpellAnimation(&selanSprite, framerate);
                selanSpellAnimation.AddFrames(2, 0, Vector<int>(), 3);
                selanSpellAnimation.AddFrames(2, 1, Vector<int>(), 2);
                selanSpellAnimation.AddFrames(2, 2, Vector<int>(), 3);
@@ -153,7 +158,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, 60, 4);
+               SimpleAnimation selanMeleeAnimation(&selanMeleeSprite, 2 * framerate, 4);
                selan.SetMeleeAnimation(&selanMeleeAnimation);
 
                SDL_Surface *guyImg(IMG_Load("test-data/guy.png"));
@@ -167,7 +172,7 @@ int main(int argc, char **argv) {
                guy.SetMaxMana(0);
                guy.SetMana(0);
                guy.SetIP(254);
-               ComplexAnimation guyAttackAnimation(&guySprite, 30);
+               ComplexAnimation guyAttackAnimation(&guySprite, framerate);
                guyAttackAnimation.AddFrames(1, 0, Vector<int>(-4, 0), 2);
                guyAttackAnimation.AddFrames(1, 0, Vector<int>(-8, 0), 2);
                guyAttackAnimation.AddFrames(2, 0, Vector<int>(-8, 0), 2);
@@ -181,7 +186,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, 60, 4);
+               SimpleAnimation guyMeleeAnimation(&guyMeleeSprite, 2 * framerate, 4);
                guy.SetMeleeAnimation(&guyMeleeAnimation);
 
                SDL_Surface *dekarImg(IMG_Load("test-data/dekar.png"));
@@ -195,7 +200,7 @@ int main(int argc, char **argv) {
                dekar.SetMaxMana(0);
                dekar.SetMana(0);
                dekar.SetIP(255);
-               ComplexAnimation dekarAttackAnimation(&dekarSprite, 30);
+               ComplexAnimation dekarAttackAnimation(&dekarSprite, framerate);
                dekarAttackAnimation.AddFrame(1, 0, Vector<int>(4, 0));
                dekarAttackAnimation.AddFrame(1, 0, Vector<int>(8, 2));
                dekarAttackAnimation.AddFrame(2, 0, Vector<int>(12, 4));
@@ -206,14 +211,14 @@ int main(int argc, char **argv) {
                dekarAttackAnimation.AddFrame(2, 2, Vector<int>(-2, 0));
                dekarAttackAnimation.AddFrames(2, 2, Vector<int>(0, 0), 3);
                dekar.SetAttackAnimation(&dekarAttackAnimation);
-               ComplexAnimation dekarSpellAnimation(&dekarSprite, 30);
+               ComplexAnimation dekarSpellAnimation(&dekarSprite, framerate);
                dekarSpellAnimation.AddFrames(2, 0, Vector<int>(), 6);
                dekarSpellAnimation.AddFrames(2, 1, Vector<int>(), 2);
                dekarSpellAnimation.AddFrames(2, 2, Vector<int>(), 3);
                dekar.SetSpellAnimation(&dekarSpellAnimation);
                SDL_Surface *dekarMeleeImg(IMG_Load("test-data/melee-dekar.png"));
                Sprite dekarMeleeSprite(dekarMeleeImg, 96, 96);
-               SimpleAnimation dekarMeleeAnimation(&dekarMeleeSprite, 60, 4);
+               SimpleAnimation dekarMeleeAnimation(&dekarMeleeSprite, 2 * framerate, 4);
                dekar.SetMeleeAnimation(&dekarMeleeAnimation);
 
                battle::Resources battleRes;
@@ -240,7 +245,7 @@ int main(int argc, char **argv) {
                Font largeFont(&largeFontSprite, 0, -2);
                battleRes.titleFont = &largeFont;
 
-               battleRes.numberAnimationPrototype = ComplexAnimation(0, 30);
+               battleRes.numberAnimationPrototype = ComplexAnimation(0, framerate);
                battleRes.numberAnimationPrototype.AddFrame(0, 0);
                battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -26));
                battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -42));
@@ -454,7 +459,7 @@ int main(int argc, char **argv) {
 
                SDL_Surface *swordAttackImg(IMG_Load("test-data/attack-sword.png"));
                Sprite swordAttackSprite(swordAttackImg, 96, 96);
-               SimpleAnimation swordAttackAnimation(&swordAttackSprite, 60, 4);
+               SimpleAnimation swordAttackAnimation(&swordAttackSprite, 2 * framerate, 4);
 
                Item zircoSword;
                zircoSword.SetName("Zirco sword");