X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmain.cpp;h=bebeed106e14bf8520b80b00aa8affaa2b07bc14;hb=0542849dfccfec1ce1477265fa0fee2401a8fb23;hp=f7707ef1cc0570053097d7e18a8271e23c921dba;hpb=7263bddbde91d555decd58f043f6b43f54ba2b00;p=l2e.git diff --git a/src/main.cpp b/src/main.cpp index f7707ef..bebeed1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,7 +17,6 @@ #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" @@ -30,6 +29,8 @@ #include "sdl/InitScreen.h" #include "sdl/InitSDL.h" +#include +#include #include #include #include @@ -46,7 +47,6 @@ using common::Ikari; using common::Inventory; using common::Item; using common::Spell; -using geometry::Point; using geometry::Vector; using graphics::ComplexAnimation; using graphics::Font; @@ -70,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); @@ -78,15 +80,15 @@ 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 monsterSprite(monsterImg, 64, 64); @@ -99,10 +101,14 @@ int main(int argc, char **argv) { monster.SetStats(Stats(14, 6, 6, 6, 6, 6, 6)); monster.SetReward(3, 5); ComplexAnimation monsterAttackAnimation(&monsterSprite, 4 * framerate); - monsterAttackAnimation.AddFrame(0, 1, Vector(16, 0)); - monsterAttackAnimation.AddFrame(0, 0, Vector(16, 0)); - monsterAttackAnimation.AddFrame(0, 1, Vector(16, 0)); + 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); @@ -259,29 +265,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); @@ -351,9 +358,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; @@ -478,6 +483,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); @@ -540,6 +546,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); @@ -601,6 +608,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); @@ -645,6 +653,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);