X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmain.cpp;h=71a29e58292b0f889661cd691db808d250226d19;hb=0f5f8a6eaa938f88fd3d1e92dec2462b30840e21;hp=841dc616f35cee60c181ee43324b29f197942ac1;hpb=f89e79ad6fdc3009657e81f3dc3765d661f4899c;p=l2e.git diff --git a/src/main.cpp b/src/main.cpp index 841dc61..71a29e5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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" @@ -29,6 +30,8 @@ #include "sdl/InitScreen.h" #include "sdl/InitSDL.h" +#include +#include #include #include #include @@ -40,6 +43,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; @@ -68,6 +72,8 @@ int main(int argc, char **argv) { const int framerate = 33; +// std::srand(std::time(0)); + try { InitSDL sdl; InitImage image(IMG_INIT_PNG); @@ -87,12 +93,24 @@ 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("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(0, 16)); + monsterAttackAnimation.AddFrame(0, 0, Vector(0, 16)); + monsterAttackAnimation.AddFrame(0, 1, Vector(0, 16)); + 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 +123,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(0, 0), 7); // TODO: maybe this could also be a pause before the battle animation @@ -137,7 +156,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(4, 0), 2); selanAttackAnimation.AddFrame(1, 0, Vector(8, 2)); @@ -171,7 +191,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(-4, 0), 2); guyAttackAnimation.AddFrames(1, 0, Vector(-8, 0), 2); @@ -199,7 +220,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(4, 0)); dekarAttackAnimation.AddFrame(1, 0, Vector(8, 2)); @@ -245,29 +267,30 @@ int main(int argc, char **argv) { Font largeFont(&largeFontSprite, 0, -2); battleRes.titleFont = &largeFont; - battleRes.numberAnimationPrototype = ComplexAnimation(0, framerate); - battleRes.numberAnimationPrototype.AddFrame(0, 0); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -26)); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -42)); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -48)); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -42)); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -26)); - battleRes.numberAnimationPrototype.AddFrame(0, 0); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -12)); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -20)); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -24)); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -20)); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -12)); - battleRes.numberAnimationPrototype.AddFrame(0, 0); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -6)); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -10)); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -12)); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -10)); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -6)); - battleRes.numberAnimationPrototype.AddFrames(0, 0, Vector(), 14); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -36)); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -32)); - battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector(0, -18)); + ComplexAnimation numberAnimationPrototype(0, framerate); + numberAnimationPrototype.AddFrame(0, 0); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -26)); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -42)); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -48)); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -42)); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -26)); + numberAnimationPrototype.AddFrame(0, 0); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -12)); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -20)); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -24)); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -20)); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -12)); + numberAnimationPrototype.AddFrame(0, 0); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -6)); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -10)); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -12)); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -10)); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -6)); + numberAnimationPrototype.AddFrames(0, 0, Vector(), 14); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -36)); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -32)); + numberAnimationPrototype.AddFrame(0, 0, Vector(0, -18)); + battleRes.numberAnimationPrototype = &numberAnimationPrototype; SDL_Surface *bigNumbersImg(IMG_Load("test-data/big-numbers.png")); Sprite bigNumbersSprite(bigNumbersImg, 16, 32); @@ -337,9 +360,7 @@ int main(int argc, char **argv) { Sprite magicTargetCursor(targetingIconsImg, 32, 32, 0, 32); Sprite itemTargetCursor(targetingIconsImg, 32, 32, 0, 64); battleRes.weaponTargetCursor = &weaponTargetCursor; - // TODO: add image for magic targeting cursor battleRes.magicTargetCursor = &magicTargetCursor; - // TODO: add image for item targeting cursor battleRes.itemTargetCursor = &itemTargetCursor; Spell resetSpell;