X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmain.cpp;h=8029a64c42d9ecb570c776990c562b1b56724203;hb=0ad5ca97b5df217329bc319d62564a9f46ba11d7;hp=5be8305346ab493da8d7abba6d1af8e6e7336f29;hpb=d2d8ff1fd5f55e8b43d48ae5e75c216492e2f032;p=l2e.git diff --git a/src/main.cpp b/src/main.cpp index 5be8305..8029a64 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)); @@ -138,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())); @@ -158,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; } @@ -186,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); @@ -213,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")); @@ -416,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]; @@ -503,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); @@ -531,6 +543,8 @@ int main(int argc, char **argv) { mapMonster.SetAnimation(&mapMonsterAnimation); mapMonster.Position() = Vector(64, 32); mapMonster.SetOrientation(Entity::ORIENTATION_SOUTH); + mapMonster.SetPartyLayout(&monstersLayout); + mapMonster.SetMonsters(&monster, 1); map1.SetEntities(&mapMonster, 1); InitScreen screen(width, height); @@ -538,7 +552,7 @@ int main(int argc, char **argv) { 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); @@ -549,7 +563,7 @@ 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(&gameState.heroes[0].MapEntity()); mapState->SetWalkingSpeed(walkSpeed);