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 parser("test-data/test.l2s", source);
86 Interpreter intp(source);
89 InitScreen screen(width, height);
91 // temporary test data
92 SDL_Surface *bg(IMG_Load("test-data/battle-bg.png"));
93 PartyLayout monstersLayout(*intp.GetPartyLayout("monstersLayout"));
94 PartyLayout heroesLayout(*intp.GetPartyLayout("heroesLayout"));
96 Monster monster(*intp.GetMonster("lizard"));
97 Hero maxim(*intp.GetHero("maxim"));
98 Hero selan(*intp.GetHero("selan"));
99 Hero guy(*intp.GetHero("guy"));
100 Hero dekar(*intp.GetHero("dekar"));
102 battle::Resources *battleRes(intp.GetBattleResources("battleResources"));
104 maxim.AddSpell(intp.GetSpell("resetSpell"));
105 Spell *strongSpell(intp.GetSpell("strongSpell"));
106 maxim.AddSpell(strongSpell);
107 selan.AddSpell(strongSpell);
108 Spell *strongerSpell(intp.GetSpell("strongerSpell"));
109 maxim.AddSpell(strongerSpell);
110 selan.AddSpell(strongerSpell);
111 Spell *championSpell(intp.GetSpell("championSpell"));
112 maxim.AddSpell(championSpell);
113 selan.AddSpell(championSpell);
114 Spell *rallySpell(intp.GetSpell("rallySpell"));
115 maxim.AddSpell(rallySpell);
116 selan.AddSpell(rallySpell);
117 selan.AddSpell(intp.GetSpell("escapeSpell"));
118 Spell *valorSpell(intp.GetSpell("valorSpell"));
119 maxim.AddSpell(valorSpell);
120 selan.AddSpell(valorSpell);
123 inventory.Add(intp.GetItem("antidoteItem"), 9);
124 inventory.Add(intp.GetItem("magicJarItem"), 4);
125 inventory.Add(intp.GetItem("hiPotionItem"), 4);
126 inventory.Add(intp.GetItem("powerPotionItem"), 4);
127 inventory.Add(intp.GetItem("escapeItem"), 2);
128 inventory.Add(intp.GetItem("sleepBallItem"), 1);
129 battleRes->inventory = &inventory;
131 maxim.SetWeapon(intp.GetItem("zircoSwordItem"));
132 maxim.SetArmor(intp.GetItem("zirconArmorItem"));
133 maxim.SetShield(intp.GetItem("holyShieldItem"));
134 maxim.SetHelmet(intp.GetItem("legendHelmItem"));
135 maxim.SetRing(intp.GetItem("sProRingItem"));
136 maxim.SetJewel(intp.GetItem("evilJewelItem"));
138 // selan.SetWeapon(intp.GetItem("zircoWhipItem"));
139 selan.SetArmor(intp.GetItem("zirconPlateItem"));
140 selan.SetShield(intp.GetItem("zircoGlovesItem"));
141 selan.SetHelmet(intp.GetItem("holyCapItem"));
142 selan.SetRing(intp.GetItem("ghostRingItem"));
143 selan.SetJewel(intp.GetItem("eagleRockItem"));
145 // guy.SetWeapon(intp.GetItem("zircoAxItem"));
146 guy.SetArmor(intp.GetItem("zirconArmorItem"));
147 guy.SetShield(intp.GetItem("megaShieldItem"));
148 guy.SetHelmet(intp.GetItem("zircoHelmetItem"));
149 guy.SetRing(intp.GetItem("powerRingItem"));
150 guy.SetJewel(intp.GetItem("evilJewelItem"));
152 // NOTE: this is actually Artea equipment
153 // dekar.SetWeapon(intp.GetItem("lizardBlowItem"));
154 dekar.SetArmor(intp.GetItem("holyRobeItem"));
155 dekar.SetShield(intp.GetItem("zircoGlovesItem"));
156 dekar.SetHelmet(intp.GetItem("holyCapItem"));
157 dekar.SetRing(intp.GetItem("rocketRingItem"));
158 dekar.SetJewel(intp.GetItem("krakenRockItem"));
160 BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, battleRes));
161 battleState->AddMonster(monster);
162 battleState->AddMonster(monster);
163 battleState->AddMonster(monster);
164 battleState->AddMonster(monster);
165 battleState->AddHero(maxim);
166 battleState->AddHero(selan);
167 battleState->AddHero(guy);
168 battleState->AddHero(dekar);
169 Application app(&screen, battleState);
170 app.Buttons().MapKey(SDLK_w, Input::PAD_UP);
171 app.Buttons().MapKey(SDLK_d, Input::PAD_RIGHT);
172 app.Buttons().MapKey(SDLK_s, Input::PAD_DOWN);
173 app.Buttons().MapKey(SDLK_a, Input::PAD_LEFT);
174 app.Buttons().MapKey(SDLK_RIGHT, Input::ACTION_A);
175 app.Buttons().MapKey(SDLK_DOWN, Input::ACTION_B);
176 app.Buttons().MapKey(SDLK_UP, Input::ACTION_X);
177 app.Buttons().MapKey(SDLK_LEFT, Input::ACTION_Y);
178 app.Buttons().MapKey(SDLK_RETURN, Input::START);
179 app.Buttons().MapKey(SDLK_SPACE, Input::SELECT);
180 app.Buttons().MapKey(SDLK_RSHIFT, Input::SHOULDER_RIGHT);
181 app.Buttons().MapKey(SDLK_LSHIFT, Input::SHOULDER_LEFT);
185 } catch (Parser::Error &e) {
186 cerr << "parsing exception in file " << e.File() << " on line " << e.Line() << ": " << e.what() << endl;
188 } catch (exception &e) {
189 cerr << "exception in main(): " << e.what() << endl;