const int width = 800;
const int height = 480;
+ const int framerate = 33;
+
try {
InitSDL sdl;
InitImage image(IMG_INIT_PNG);
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"));
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));
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);
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"));
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);
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"));
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));
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;
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));
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");