4 * Created on: Aug 1, 2012
8 #include "app/Application.h"
10 #include "battle/BattleState.h"
11 #include "battle/Hero.h"
12 #include "battle/Monster.h"
13 #include "battle/PartyLayout.h"
14 #include "battle/Resources.h"
15 #include "battle/Stats.h"
16 #include "common/Ikari.h"
17 #include "common/Inventory.h"
18 #include "common/Item.h"
19 #include "common/Spell.h"
20 #include "geometry/Vector.h"
21 #include "graphics/ComplexAnimation.h"
22 #include "graphics/Font.h"
23 #include "graphics/Frame.h"
24 #include "graphics/Gauge.h"
25 #include "graphics/Menu.h"
26 #include "graphics/SimpleAnimation.h"
27 #include "graphics/Sprite.h"
28 #include "loader/Interpreter.h"
29 #include "loader/ParsedSource.h"
30 #include "loader/Parser.h"
31 #include "sdl/InitImage.h"
32 #include "sdl/InitScreen.h"
33 #include "sdl/InitSDL.h"
40 #include <SDL_image.h>
42 using app::Application;
44 using battle::BattleState;
46 using battle::Monster;
47 using battle::PartyLayout;
50 using common::Inventory;
53 using geometry::Vector;
54 using graphics::ComplexAnimation;
56 using graphics::Frame;
57 using graphics::Gauge;
59 using graphics::SimpleAnimation;
60 using graphics::Sprite;
61 using loader::Interpreter;
62 using loader::ParsedSource;
65 using sdl::InitScreen;
73 int main(int argc, char **argv) {
74 const int width = 800;
75 const int height = 480;
77 // std::srand(std::time(0));
81 InitImage image(IMG_INIT_PNG);
84 Parser("test-data/test.l2s", source).Parse();
85 Parser("test-data/ikaris.l2s", source).Parse();
86 Parser("test-data/items.l2s", source).Parse();
87 Parser("test-data/spells.l2s", source).Parse();
88 Interpreter intp(source);
91 InitScreen screen(width, height);
93 // temporary test data
94 SDL_Surface *bg(IMG_Load("test-data/battle-bg.png"));
95 PartyLayout monstersLayout(*intp.GetPartyLayout("monstersLayout"));
96 PartyLayout heroesLayout(*intp.GetPartyLayout("heroesLayout"));
98 Monster monster(*intp.GetMonster("lizard"));
99 Hero maxim(*intp.GetHero("maxim"));
100 Hero selan(*intp.GetHero("selan"));
101 Hero guy(*intp.GetHero("guy"));
102 Hero dekar(*intp.GetHero("dekar"));
104 battle::Resources *battleRes(intp.GetBattleResources("battleResources"));
106 maxim.AddSpell(intp.GetSpell("resetSpell"));
107 Spell *strongSpell(intp.GetSpell("strongSpell"));
108 maxim.AddSpell(strongSpell);
109 selan.AddSpell(strongSpell);
110 Spell *strongerSpell(intp.GetSpell("strongerSpell"));
111 maxim.AddSpell(strongerSpell);
112 selan.AddSpell(strongerSpell);
113 Spell *championSpell(intp.GetSpell("championSpell"));
114 maxim.AddSpell(championSpell);
115 selan.AddSpell(championSpell);
116 Spell *rallySpell(intp.GetSpell("rallySpell"));
117 maxim.AddSpell(rallySpell);
118 selan.AddSpell(rallySpell);
119 selan.AddSpell(intp.GetSpell("escapeSpell"));
120 Spell *valorSpell(intp.GetSpell("valorSpell"));
121 maxim.AddSpell(valorSpell);
122 selan.AddSpell(valorSpell);
125 inventory.Add(intp.GetItem("antidoteItem"), 9);
126 inventory.Add(intp.GetItem("magicJarItem"), 4);
127 inventory.Add(intp.GetItem("hiPotionItem"), 4);
128 inventory.Add(intp.GetItem("powerPotionItem"), 4);
129 inventory.Add(intp.GetItem("escapeItem"), 2);
130 inventory.Add(intp.GetItem("sleepBallItem"), 1);
131 battleRes->inventory = &inventory;
133 maxim.SetWeapon(intp.GetItem("zircoSwordItem"));
134 maxim.SetArmor(intp.GetItem("zirconArmorItem"));
135 maxim.SetShield(intp.GetItem("holyShieldItem"));
136 maxim.SetHelmet(intp.GetItem("legendHelmItem"));
137 maxim.SetRing(intp.GetItem("sProRingItem"));
138 maxim.SetJewel(intp.GetItem("evilJewelItem"));
140 // selan.SetWeapon(intp.GetItem("zircoWhipItem"));
141 selan.SetArmor(intp.GetItem("zirconPlateItem"));
142 selan.SetShield(intp.GetItem("zircoGlovesItem"));
143 selan.SetHelmet(intp.GetItem("holyCapItem"));
144 selan.SetRing(intp.GetItem("ghostRingItem"));
145 selan.SetJewel(intp.GetItem("eagleRockItem"));
147 // guy.SetWeapon(intp.GetItem("zircoAxItem"));
148 guy.SetArmor(intp.GetItem("zirconArmorItem"));
149 guy.SetShield(intp.GetItem("megaShieldItem"));
150 guy.SetHelmet(intp.GetItem("zircoHelmetItem"));
151 guy.SetRing(intp.GetItem("powerRingItem"));
152 guy.SetJewel(intp.GetItem("evilJewelItem"));
154 // NOTE: this is actually Artea equipment
155 // dekar.SetWeapon(intp.GetItem("lizardBlowItem"));
156 dekar.SetArmor(intp.GetItem("holyRobeItem"));
157 dekar.SetShield(intp.GetItem("zircoGlovesItem"));
158 dekar.SetHelmet(intp.GetItem("holyCapItem"));
159 dekar.SetRing(intp.GetItem("rocketRingItem"));
160 dekar.SetJewel(intp.GetItem("krakenRockItem"));
162 BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, battleRes));
163 battleState->AddMonster(monster);
164 battleState->AddMonster(monster);
165 battleState->AddMonster(monster);
166 battleState->AddMonster(monster);
167 battleState->AddHero(maxim);
168 battleState->AddHero(selan);
169 battleState->AddHero(guy);
170 battleState->AddHero(dekar);
171 Application app(&screen, battleState);
172 app.Buttons().MapKey(SDLK_w, Input::PAD_UP);
173 app.Buttons().MapKey(SDLK_d, Input::PAD_RIGHT);
174 app.Buttons().MapKey(SDLK_s, Input::PAD_DOWN);
175 app.Buttons().MapKey(SDLK_a, Input::PAD_LEFT);
176 app.Buttons().MapKey(SDLK_RIGHT, Input::ACTION_A);
177 app.Buttons().MapKey(SDLK_DOWN, Input::ACTION_B);
178 app.Buttons().MapKey(SDLK_UP, Input::ACTION_X);
179 app.Buttons().MapKey(SDLK_LEFT, Input::ACTION_Y);
180 app.Buttons().MapKey(SDLK_RETURN, Input::START);
181 app.Buttons().MapKey(SDLK_SPACE, Input::SELECT);
182 app.Buttons().MapKey(SDLK_RSHIFT, Input::SHOULDER_RIGHT);
183 app.Buttons().MapKey(SDLK_LSHIFT, Input::SHOULDER_LEFT);
187 } catch (Parser::Error &e) {
188 cerr << "parsing exception in file " << e.File() << " on line " << e.Line() << ": " << e.what() << endl;
190 } catch (exception &e) {
191 cerr << "exception in main(): " << e.what() << endl;