X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmain.cpp;h=26a85736b4eaf0442f53016524b15374960ae60d;hb=978ccdf2644bc445c864dbe581ead365b238cff8;hp=ff49b66bb578b11a9536fb476abcb7b868d6b75d;hpb=616330670a0c3d9d4554c145e997129747d05979;p=l2e.git diff --git a/src/main.cpp b/src/main.cpp index ff49b66..26a8573 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,6 +13,7 @@ #include "battle/Monster.h" #include "battle/PartyLayout.h" #include "battle/Resources.h" +#include "common/GameConfig.h" #include "common/GameState.h" #include "common/Hero.h" #include "common/Ikari.h" @@ -58,6 +59,7 @@ using app::Input; using battle::BattleState; using battle::Monster; using battle::PartyLayout; +using common::GameConfig; using common::GameState; using common::Hero; using common::Ikari; @@ -102,7 +104,7 @@ int main(int argc, char **argv) { const int tileSize = 32; const float walkSpeed = 128.0f; - const bool battle(false); + bool battle(false); // std::srand(std::time(0)); @@ -127,6 +129,7 @@ int main(int argc, char **argv) { Sprite::CreateTypeDescription(); Stats::CreateTypeDescription(); common::TargetingMode::CreateTypeDescription(); + Entity::CreateTypeDescription(); Arguments args; args.Read(argc, argv); @@ -137,7 +140,7 @@ int main(int argc, char **argv) { Parser(*i, source).Parse(); } - switch (args.DetectRunLevel()) { + switch (args.GetRunLevel()) { case Arguments::WRITE: { int length(std::strlen(args.OutfilePath())); @@ -157,7 +160,15 @@ int main(int argc, char **argv) { std::cout << source << std::endl; return 0; } + case Arguments::SOURCE_WIKI: { + TypeDescription::WriteSourceWiki(std::cout); + return 0; + } + case Arguments::BATTLE: + battle = true; + break; case Arguments::PLAY: + case Arguments::MAP: break; } @@ -185,15 +196,17 @@ int main(int argc, char **argv) { gameState.party[2] = &gameState.heroes[2]; gameState.party[3] = &gameState.heroes[3]; + GameConfig gameConfig; + gameConfig.state = &gameState; + gameConfig.heroesLayout = caster.GetPartyLayout("heroesLayout"); + gameConfig.battleResources = caster.GetBattleResources("battleResources"); + // temporary test data SDL_Surface *bg(IMG_Load("test-data/battle-bg.png")); PartyLayout monstersLayout(*caster.GetPartyLayout("monstersLayout")); - PartyLayout heroesLayout(*caster.GetPartyLayout("heroesLayout")); Monster monster(*caster.GetMonster("lizard")); - battle::Resources *battleRes(caster.GetBattleResources("battleResources")); - gameState.heroes[0].AddSpell(caster.GetSpell("resetSpell")); Spell *strongSpell(caster.GetSpell("strongSpell")); gameState.heroes[0].AddSpell(strongSpell); @@ -212,14 +225,12 @@ int main(int argc, char **argv) { gameState.heroes[0].AddSpell(valorSpell); gameState.heroes[1].AddSpell(valorSpell); - Inventory inventory; - inventory.Add(caster.GetItem("antidoteItem"), 9); - inventory.Add(caster.GetItem("magicJarItem"), 4); - inventory.Add(caster.GetItem("hiPotionItem"), 4); - inventory.Add(caster.GetItem("powerPotionItem"), 4); - inventory.Add(caster.GetItem("escapeItem"), 2); - inventory.Add(caster.GetItem("sleepBallItem"), 1); - battleRes->inventory = &inventory; + gameState.inventory.Add(caster.GetItem("antidoteItem"), 9); + gameState.inventory.Add(caster.GetItem("magicJarItem"), 4); + gameState.inventory.Add(caster.GetItem("hiPotionItem"), 4); + gameState.inventory.Add(caster.GetItem("powerPotionItem"), 4); + gameState.inventory.Add(caster.GetItem("escapeItem"), 2); + gameState.inventory.Add(caster.GetItem("sleepBallItem"), 1); gameState.heroes[0].SetWeapon(caster.GetItem("zircoSwordItem")); gameState.heroes[0].SetArmor(caster.GetItem("zirconArmorItem")); @@ -415,6 +426,7 @@ int main(int argc, char **argv) { map1.SetTileset(&tileset); map1.SetTriggers(triggers1, 1); map1.SetWidth(2); + map1.SetBattleBackground(bg); Tile tiles3[64]; @@ -502,6 +514,7 @@ int main(int argc, char **argv) { map2.SetTileset(&tileset); map2.SetTriggers(triggers2, 1); map2.SetWidth(1); + map2.SetBattleBackground(bg); triggers1[0].map = &map2; triggers1[0].target = Vector(6, 2); @@ -509,51 +522,43 @@ int main(int argc, char **argv) { triggers2[0].map = &map1; triggers2[0].target = Vector(8, 3); - SimpleAnimation mapMaximAnimation(gameState.heroes[0].MapSprite(), (tileSize/walkSpeed) / 2 * 1000, 2, 0, 0, true); - Entity mapMaxim; - mapMaxim.SetAnimation(&mapMaximAnimation); - mapMaxim.Position() = Vector(64, 128); - mapMaxim.SpriteOffset() = Vector(0, -32); - - SimpleAnimation mapSelanAnimation(gameState.heroes[1].MapSprite(), (tileSize/walkSpeed) / 2 * 1000, 2, 0, 0, true); - Entity mapSelan; - mapSelan.SetAnimation(&mapSelanAnimation); - mapSelan.Position() = Vector(64, 128); - mapSelan.SpriteOffset() = Vector(0, -32); - mapSelan.SetFlags(Entity::FLAG_NONBLOCKING); - mapMaxim.AddFollower(&mapSelan); - - SimpleAnimation mapGuyAnimation(gameState.heroes[2].MapSprite(), (tileSize/walkSpeed) / 2 * 1000, 2, 0, 0, true); - Entity mapGuy; - mapGuy.SetAnimation(&mapGuyAnimation); - mapGuy.Position() = Vector(64, 128); - mapGuy.SpriteOffset() = Vector(0, -32); - mapGuy.SetFlags(Entity::FLAG_NONBLOCKING); - mapSelan.AddFollower(&mapGuy); - - SimpleAnimation mapDekarAnimation(gameState.heroes[3].MapSprite(), (tileSize/walkSpeed) / 2 * 1000, 2, 0, 0, true); - Entity mapDekar; - mapDekar.SetAnimation(&mapDekarAnimation); - mapDekar.Position() = Vector(64, 128); - mapDekar.SpriteOffset() = Vector(0, -32); - mapDekar.SetFlags(Entity::FLAG_NONBLOCKING); - mapGuy.AddFollower(&mapDekar); + gameState.heroes[0].MapEntity().Position() = Vector(64, 128); + + gameState.heroes[1].MapEntity().Position() = Vector(64, 128); + gameState.heroes[1].MapEntity().SetFlags(Entity::FLAG_NONBLOCKING); + gameState.heroes[0].MapEntity().AddFollower(&gameState.heroes[1].MapEntity()); + + gameState.heroes[2].MapEntity().Position() = Vector(64, 128); + gameState.heroes[2].MapEntity().SetFlags(Entity::FLAG_NONBLOCKING); + gameState.heroes[1].MapEntity().AddFollower(&gameState.heroes[2].MapEntity()); + + gameState.heroes[3].MapEntity().Position() = Vector(64, 128); + gameState.heroes[3].MapEntity().SetFlags(Entity::FLAG_NONBLOCKING); + gameState.heroes[2].MapEntity().AddFollower(&gameState.heroes[3].MapEntity()); + + Entity mapPopulation[2]; + map1.SetEntities(mapPopulation, 2); SDL_Surface *mapMonsterImg(IMG_Load("test-data/monster-map.png")); Sprite mapMonsterSprite(mapMonsterImg, 32, 32); SimpleAnimation mapMonsterAnimation(&mapMonsterSprite, 500, 2, 0, 0, true); - Entity mapMonster; - mapMonster.SetAnimation(&mapMonsterAnimation); - mapMonster.Position() = Vector(64, 32); - mapMonster.SetOrientation(Entity::ORIENTATION_SOUTH); - map1.SetEntities(&mapMonster, 1); + mapPopulation[0].SetAnimation(&mapMonsterAnimation); + mapPopulation[0].Position() = Vector(64, 32); + mapPopulation[0].SetOrientation(Entity::ORIENTATION_SOUTH); + mapPopulation[0].SetPartyLayout(&monstersLayout); + mapPopulation[0].SetMonsters(&monster, 1); + + Sprite blockSprite(tilesetImg, tileSize, tileSize, 3 * tileSize, 1 * tileSize); + mapPopulation[1].SetSprite(&blockSprite); + mapPopulation[1].Position() = Vector(64, 160); + mapPopulation[1].SetFlags(Entity::FLAG_PUSHABLE | Entity::FLAG_FIXED_ORIENTATION); InitScreen screen(width, height); app::State *state(0); if (battle) { - BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, battleRes)); + BattleState *battleState(new BattleState(&gameConfig, bg, &monstersLayout)); battleState->AddMonster(monster); battleState->AddMonster(monster); battleState->AddMonster(monster); @@ -564,11 +569,11 @@ int main(int argc, char **argv) { battleState->AddHero(gameState.heroes[3]); state = battleState; } else { - MapState *mapState(new MapState(&map1)); + MapState *mapState(new MapState(&gameConfig, &map1)); - mapState->ControlEntity(&mapMaxim); + mapState->ControlEntity(&gameState.heroes[0].MapEntity()); mapState->SetWalkingSpeed(walkSpeed); - mapMonster.StartAnimation(*mapState); + mapPopulation[0].StartAnimation(*mapState); state = mapState; }