X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmain.cpp;h=3dc37d83327f89d558784f150833ce1d8c7b9e34;hb=70641f2eb3f9fce8c89dcbf345e202050609a142;hp=841dc616f35cee60c181ee43324b29f197942ac1;hpb=f89e79ad6fdc3009657e81f3dc3765d661f4899c;p=l2e.git diff --git a/src/main.cpp b/src/main.cpp index 841dc61..3dc37d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,11 +12,11 @@ #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" #include "common/Spell.h" -#include "geometry/Point.h" #include "geometry/Vector.h" #include "graphics/ComplexAnimation.h" #include "graphics/Font.h" @@ -29,6 +29,8 @@ #include "sdl/InitScreen.h" #include "sdl/InitSDL.h" +#include +#include #include #include #include @@ -40,11 +42,11 @@ using battle::BattleState; using battle::Hero; using battle::Monster; using battle::PartyLayout; +using battle::Stats; using common::Ikari; using common::Inventory; using common::Item; using common::Spell; -using geometry::Point; using geometry::Vector; using graphics::ComplexAnimation; using graphics::Font; @@ -68,6 +70,8 @@ int main(int argc, char **argv) { const int framerate = 33; +// std::srand(std::time(0)); + try { InitSDL sdl; InitImage image(IMG_INIT_PNG); @@ -76,23 +80,35 @@ int main(int argc, char **argv) { // temporary test data SDL_Surface *bg(IMG_Load("test-data/battle-bg.png")); PartyLayout monstersLayout; - monstersLayout.AddPosition(Point(88, 88)); - monstersLayout.AddPosition(Point(128, 88)); - monstersLayout.AddPosition(Point(168, 88)); - monstersLayout.AddPosition(Point(208, 88)); + monstersLayout.AddPosition(Vector(88, 88)); + monstersLayout.AddPosition(Vector(128, 88)); + monstersLayout.AddPosition(Vector(168, 88)); + monstersLayout.AddPosition(Vector(208, 88)); PartyLayout heroesLayout; - heroesLayout.AddPosition(Point(48, 136)); - heroesLayout.AddPosition(Point(128, 136)); - heroesLayout.AddPosition(Point(80, 152)); - heroesLayout.AddPosition(Point(160, 152)); + heroesLayout.AddPosition(Vector(48, 136)); + heroesLayout.AddPosition(Vector(128, 136)); + heroesLayout.AddPosition(Vector(80, 152)); + heroesLayout.AddPosition(Vector(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,9 +121,9 @@ 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 + maximAttackAnimation.AddFrames(1, 0, Vector(0, 0), 7); maximAttackAnimation.AddFrames(1, 0, Vector(4, -1), 2); maximAttackAnimation.AddFrames(2, 0, Vector(4, -2), 2); maximAttackAnimation.AddFrames(2, 0, Vector(6, -2), 2); @@ -116,7 +132,7 @@ int main(int argc, char **argv) { maximAttackAnimation.AddFrames(2, 1, Vector(0, 0), 1); maximAttackAnimation.AddFrames(2, 2, Vector(0, 0), 2); maximAttackAnimation.AddFrames(2, 2, Vector(2, 0), 1); - maximAttackAnimation.AddFrames(1, 0, Vector(0, 0), 7); // TODO: maybe this could also be a pause between two animations + maximAttackAnimation.AddFrames(1, 0, Vector(0, 0), 7); maxim.SetAttackAnimation(&maximAttackAnimation); ComplexAnimation maximSpellAnimation(&maximSprite, 5 * framerate); maximSpellAnimation.AddFrames(3, 0, Vector(), 2); @@ -137,7 +153,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 +188,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 +217,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 +264,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 +357,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; @@ -464,6 +482,7 @@ int main(int argc, char **argv) { Item zircoSword; zircoSword.SetName("Zirco sword"); zircoSword.SetMenuIcon(&swordIcon); + zircoSword.GetTargetingMode().TargetSingleEnemy(); Ikari firestorm; firestorm.SetName("Firestorm"); firestorm.SetCost(224); @@ -488,7 +507,7 @@ int main(int argc, char **argv) { Ikari lightGuard; lightGuard.SetName("Light guard"); lightGuard.SetCost(128); - lightGuard.GetTargetingMode().TargetAllAllies(); // FIXME: actually only targets self + lightGuard.GetTargetingMode().TargetAllAllies(); // actually only targets self lightGuard.SetMagical(); holyShield.SetIkari(&lightGuard); maxim.SetShield(&holyShield); @@ -498,7 +517,7 @@ int main(int argc, char **argv) { Ikari boomerang; boomerang.SetName("Boomerang"); boomerang.SetCost(164); - boomerang.GetTargetingMode().TargetAllAllies(); // FIXME: actually only targets self + boomerang.GetTargetingMode().TargetAllAllies(); // actually only targets self boomerang.SetMagical(); legendHelm.SetIkari(&boomerang); maxim.SetHelmet(&legendHelm); @@ -526,6 +545,7 @@ int main(int argc, char **argv) { Item zircoWhip; zircoWhip.SetName("Zirco whip"); zircoWhip.SetMenuIcon(&rodIcon); + zircoWhip.GetTargetingMode().TargetSingleEnemy(); Ikari thundershriek; thundershriek.SetName("Thundershriek"); thundershriek.SetCost(224); @@ -587,6 +607,7 @@ int main(int argc, char **argv) { Item zircoAx; zircoAx.SetName("Zirco ax"); zircoAx.SetMenuIcon(&axIcon); + zircoAx.GetTargetingMode().TargetSingleEnemy(); Ikari torrent; torrent.SetName("Torrent"); torrent.SetCost(224); @@ -601,7 +622,7 @@ int main(int argc, char **argv) { Ikari ironBarrier; ironBarrier.SetName("Iron barrier"); ironBarrier.SetCost(255); - ironBarrier.GetTargetingMode().TargetAllAllies(); // FIXME: actually only targets self + ironBarrier.GetTargetingMode().TargetAllAllies(); // actually only targets self ironBarrier.SetMagical(); megaShield.SetIkari(&ironBarrier); guy.SetShield(&megaShield); @@ -631,6 +652,7 @@ int main(int argc, char **argv) { Item lizardBlow; lizardBlow.SetName("Lizard blow"); lizardBlow.SetMenuIcon(&swordIcon); + lizardBlow.GetTargetingMode().TargetSingleEnemy(); Ikari dragonRush; dragonRush.SetName("Dragon rush"); dragonRush.SetCost(164);