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 const int framerate = 33;
79 // std::srand(std::time(0));
83 InitImage image(IMG_INIT_PNG);
86 Parser parser("test-data/test.l2s", source);
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;
96 monstersLayout.AddPosition(Vector<Uint8>(88, 88));
97 monstersLayout.AddPosition(Vector<Uint8>(128, 88));
98 monstersLayout.AddPosition(Vector<Uint8>(168, 88));
99 monstersLayout.AddPosition(Vector<Uint8>(208, 88));
100 PartyLayout heroesLayout;
101 heroesLayout.AddPosition(Vector<Uint8>(48, 136));
102 heroesLayout.AddPosition(Vector<Uint8>(128, 136));
103 heroesLayout.AddPosition(Vector<Uint8>(80, 152));
104 heroesLayout.AddPosition(Vector<Uint8>(160, 152));
106 Monster monster(*intp.GetMonster("lizard"));
107 Hero maxim(*intp.GetHero("maxim"));
108 Hero selan(*intp.GetHero("selan"));
109 Hero guy(*intp.GetHero("guy"));
110 Hero dekar(*intp.GetHero("dekar"));
112 battle::Resources battleRes;
114 SDL_Surface *swapCursorImg(IMG_Load("test-data/swap-cursor.png"));
115 Sprite swapCursorSprite(swapCursorImg, 32, 32);
116 battleRes.swapCursor = &swapCursorSprite;
117 SDL_Surface *attackIconsImg(IMG_Load("test-data/attack-type-icons.png"));
118 Sprite attackIconsSprite(attackIconsImg, 32, 32);
119 battleRes.attackIcons = &attackIconsSprite;
120 SDL_Surface *attackChoiceIconsImg(IMG_Load("test-data/attack-choice-icons.png"));
121 Sprite attackChoiceIconsSprite(attackChoiceIconsImg, 16, 16);
122 battleRes.attackChoiceIcons = &attackChoiceIconsSprite;
123 SDL_Surface *moveIconsImg(IMG_Load("test-data/move-icons.png"));
124 Sprite moveIconsSprite(moveIconsImg, 32, 32);
125 battleRes.moveIcons = &moveIconsSprite;
127 SDL_Surface *titleFrameImg(IMG_Load("test-data/title-frame.png"));
128 Frame titleFrame(titleFrameImg, 16, 16);
129 battleRes.titleFrame = &titleFrame;
131 SDL_Surface *largeFontImg(IMG_Load("test-data/large-font.png"));
132 Sprite largeFontSprite(largeFontImg, 16, 32);
133 Font largeFont(&largeFontSprite, 0, -2);
134 battleRes.titleFont = &largeFont;
136 ComplexAnimation numberAnimationPrototype(0, framerate);
137 numberAnimationPrototype.AddFrame(0, 0);
138 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -26));
139 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -42));
140 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -48));
141 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -42));
142 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -26));
143 numberAnimationPrototype.AddFrame(0, 0);
144 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
145 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -20));
146 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -24));
147 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -20));
148 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
149 numberAnimationPrototype.AddFrame(0, 0);
150 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -6));
151 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -10));
152 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
153 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -10));
154 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -6));
155 numberAnimationPrototype.AddFrames(0, 0, Vector<int>(), 14);
156 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -36));
157 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -32));
158 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -18));
159 battleRes.numberAnimationPrototype = &numberAnimationPrototype;
161 SDL_Surface *bigNumbersImg(IMG_Load("test-data/big-numbers.png"));
162 Sprite bigNumbersSprite(bigNumbersImg, 16, 32);
163 battleRes.bigNumberSprite = &bigNumbersSprite;
164 SDL_Surface *bigGreenNumbersImg(IMG_Load("test-data/big-green-numbers.png"));
165 Sprite bigGreenNumbersSprite(bigGreenNumbersImg, 16, 32);
166 battleRes.greenNumberSprite = &bigGreenNumbersSprite;
168 SDL_Surface *heroTagImg(IMG_Load("test-data/hero-tag-sprites.png"));
169 Sprite heroTagSprite(heroTagImg, 32, 16);
170 battleRes.heroTagLabels = &heroTagSprite;
171 battleRes.levelLabelCol = 0;
172 battleRes.levelLabelRow = 0;
173 battleRes.healthLabelCol = 0;
174 battleRes.healthLabelRow = 1;
175 battleRes.manaLabelCol = 0;
176 battleRes.manaLabelRow = 2;
177 battleRes.moveLabelCol = 0;
178 battleRes.moveLabelRow = 3;
179 battleRes.ikariLabelCol = 0;
180 battleRes.ikariLabelRow = 4;
182 SDL_Surface *numbersImg(IMG_Load("test-data/numbers.png"));
183 Sprite numbersSprite(numbersImg, 16, 16);
184 Font heroTagFont(&numbersSprite, 0, -3);
185 battleRes.heroTagFont = &heroTagFont;
186 SDL_Surface *tagFramesImg(IMG_Load("test-data/tag-frames.png"));
187 Frame heroTagFrame(tagFramesImg, 16, 16, 1, 1, 0, 33);
188 battleRes.heroTagFrame = &heroTagFrame;
189 Frame activeHeroTagFrame(tagFramesImg, 16, 16);
190 battleRes.activeHeroTagFrame = &activeHeroTagFrame;
191 SDL_Surface *smallTagFrameImg(IMG_Load("test-data/small-tag-frame.png"));
192 Frame smallTagFrame(smallTagFrameImg, 8, 16);
193 battleRes.smallHeroTagFrame = &smallTagFrame;
194 Frame lastSmallTagFrame(smallTagFrameImg, 8, 16, 1, 1, 0, 33);
195 battleRes.lastSmallHeroTagFrame = &lastSmallTagFrame;
196 battleRes.heroesBgColor = SDL_MapRGB(screen.Screen()->format, 0x18, 0x28, 0x31);
198 SDL_Surface *gauges(IMG_Load("test-data/gauges.png"));
199 Gauge healthGauge(gauges, 0, 16, 0, 0, 16, 6, 1, 6);
200 battleRes.healthGauge = &healthGauge;
201 Gauge manaGauge(gauges, 0, 32, 0, 0, 16, 6, 1, 6);
202 battleRes.manaGauge = &manaGauge;
203 Gauge ikariGauge(gauges, 0, 48, 0, 0, 16, 6, 1, 6);
204 battleRes.ikariGauge = &ikariGauge;
206 SDL_Surface *selectFrameImg(IMG_Load("test-data/select-frame.png"));
207 Frame selectFrame(selectFrameImg, 16, 16);
208 battleRes.selectFrame = &selectFrame;
210 SDL_Surface *normalFontImg(IMG_Load("test-data/normal-font.png"));
211 Sprite normalFontSprite(normalFontImg, 16, 16);
212 Font normalFont(&normalFontSprite, 0, -2);
213 battleRes.normalFont = &normalFont;
215 SDL_Surface *disabledFontImg(IMG_Load("test-data/disabled-font.png"));
216 Sprite disabledFontSprite(disabledFontImg, 16, 16);
217 Font disabledFont(&disabledFontSprite, 0, -2);
218 battleRes.disabledFont = &disabledFont;
220 SDL_Surface *handCursorImg(IMG_Load("test-data/cursor-hand.png"));
221 Sprite handCursorSprite(handCursorImg, 32, 32);
222 battleRes.menuCursor = &handCursorSprite;
224 SDL_Surface *targetingIconsImg(IMG_Load("test-data/targeting-icons.png"));
225 Sprite weaponTargetCursor(targetingIconsImg, 32, 32);
226 Sprite magicTargetCursor(targetingIconsImg, 32, 32, 0, 32);
227 Sprite itemTargetCursor(targetingIconsImg, 32, 32, 0, 64);
228 battleRes.weaponTargetCursor = &weaponTargetCursor;
229 battleRes.magicTargetCursor = &magicTargetCursor;
230 battleRes.itemTargetCursor = &itemTargetCursor;
233 resetSpell.SetName("Reset");
234 maxim.AddSpell(&resetSpell);
236 strongSpell.SetName("Strong");
237 strongSpell.SetCost(3);
238 strongSpell.SetUsableInBattle();
239 strongSpell.GetTargetingMode().TargetMultipleAllies();
240 maxim.AddSpell(&strongSpell);
241 selan.AddSpell(&strongSpell);
243 strongerSpell.SetName("Stronger");
244 strongerSpell.SetCost(8);
245 strongerSpell.SetUsableInBattle();
246 strongerSpell.GetTargetingMode().TargetMultipleAllies();
247 maxim.AddSpell(&strongerSpell);
248 selan.AddSpell(&strongerSpell);
250 championSpell.SetName("Champion");
251 championSpell.SetCost(16);
252 championSpell.SetUsableInBattle();
253 championSpell.GetTargetingMode().TargetMultipleAllies();
254 maxim.AddSpell(&championSpell);
255 selan.AddSpell(&championSpell);
257 rallySpell.SetName("Rally");
258 rallySpell.SetCost(10);
259 rallySpell.SetUsableInBattle();
260 rallySpell.GetTargetingMode().TargetMultipleAllies();
261 maxim.AddSpell(&rallySpell);
262 selan.AddSpell(&rallySpell);
264 escapeSpell.SetName("Escape");
265 escapeSpell.SetCost(8);
266 selan.AddSpell(&escapeSpell);
268 valorSpell.SetName("Valor");
269 valorSpell.SetCost(30);
270 valorSpell.SetUsableInBattle();
271 valorSpell.GetTargetingMode().TargetMultipleAllies();
272 maxim.AddSpell(&valorSpell);
273 selan.AddSpell(&valorSpell);
275 battleRes.spellMenuHeadline = "Please choose a spell.";
276 battleRes.spellMenuPrototype = Menu<const Spell *>(&normalFont, &disabledFont, &handCursorSprite, 9, 6, 8, 0, 2, 32, 2, ':');
278 SDL_Surface *itemIcons(IMG_Load("test-data/item-icons.png"));
279 Sprite potionIcon(itemIcons, 16, 16);
280 Sprite ballIcon(itemIcons, 16, 16, 0, 16);
281 Sprite crankIcon(itemIcons, 16, 16, 0, 32);
282 Sprite spearIcon(itemIcons, 16, 16, 0, 48);
283 Sprite swordIcon(itemIcons, 16, 16, 0, 64);
284 Sprite axIcon(itemIcons, 16, 16, 0, 80);
285 Sprite rodIcon(itemIcons, 16, 16, 0, 96);
286 Sprite armorIcon(itemIcons, 16, 16, 0, 112);
287 Sprite shieldIcon(itemIcons, 16, 16, 0, 128);
288 Sprite helmetIcon(itemIcons, 16, 16, 0, 144);
289 Sprite ringIcon(itemIcons, 16, 16, 0, 160);
290 Sprite jewelIcon(itemIcons, 16, 16, 0, 176);
292 battleRes.weaponMenuIcon = &swordIcon;
293 battleRes.armorMenuIcon = &armorIcon;
294 battleRes.shieldMenuIcon = &shieldIcon;
295 battleRes.helmetMenuIcon = &helmetIcon;
296 battleRes.ringMenuIcon = &ringIcon;
297 battleRes.jewelMenuIcon = &jewelIcon;
301 antidote.SetName("Antidote");
302 antidote.SetMenuIcon(&potionIcon);
303 antidote.SetUsableInBattle();
304 antidote.GetTargetingMode().TargetSingleAlly();
305 inventory.Add(&antidote, 9);
307 magicJar.SetName("Magic jar");
308 magicJar.SetMenuIcon(&potionIcon);
309 magicJar.SetUsableInBattle();
310 magicJar.GetTargetingMode().TargetSingleAlly();
311 inventory.Add(&magicJar, 4);
313 hiPotion.SetName("Hi-Potion");
314 hiPotion.SetMenuIcon(&potionIcon);
315 hiPotion.SetUsableInBattle();
316 hiPotion.GetTargetingMode().TargetSingleAlly();
317 inventory.Add(&hiPotion, 4);
319 powerPotion.SetName("Power potion");
320 powerPotion.SetMenuIcon(&potionIcon);
321 inventory.Add(&powerPotion, 4);
323 escape.SetName("Escape");
324 inventory.Add(&escape, 2);
326 sleepBall.SetName("Sleep ball");
327 sleepBall.SetMenuIcon(&ballIcon);
328 sleepBall.SetUsableInBattle();
329 sleepBall.GetTargetingMode().TargetSingleEnemy();
330 inventory.Add(&sleepBall, 1);
332 multiBall.SetName("Multi-ball!");
333 multiBall.SetMenuIcon(&ballIcon);
334 multiBall.SetUsableInBattle();
335 multiBall.GetTargetingMode().TargetMultipleEnemies();
336 inventory.Add(&multiBall, 1);
338 figgoru.SetName("Figgoru");
339 figgoru.SetMenuIcon(&crankIcon);
340 figgoru.GetTargetingMode().TargetAllEnemies();
341 inventory.Add(&figgoru, 1);
342 battleRes.inventory = &inventory;
344 battleRes.itemMenuHeadline = "Please choose an item.";
345 battleRes.itemMenuPrototype = Menu<const common::Item *>(&normalFont, &disabledFont, &handCursorSprite, 15, 6, 8, 16, 1, 32, 2, ':');
347 SDL_Surface *swordAttackImg(IMG_Load("test-data/attack-sword.png"));
348 Sprite swordAttackSprite(swordAttackImg, 96, 96);
349 SimpleAnimation swordAttackAnimation(&swordAttackSprite, 2 * framerate, 4);
352 zircoSword.SetName("Zirco sword");
353 zircoSword.SetMenuIcon(&swordIcon);
354 zircoSword.GetTargetingMode().TargetSingleEnemy();
356 firestorm.SetName("Firestorm");
357 firestorm.SetCost(224);
358 firestorm.GetTargetingMode().TargetAllEnemies();
359 firestorm.SetPhysical();
360 zircoSword.SetIkari(&firestorm);
361 zircoSword.SetAttackAnimation(&swordAttackAnimation);
362 maxim.SetWeapon(&zircoSword);
364 zirconArmor.SetName("Zircon armor");
365 zirconArmor.SetMenuIcon(&armorIcon);
367 magicCure.SetName("Magic cure");
368 magicCure.SetCost(128);
369 magicCure.GetTargetingMode().TargetSingleAlly();
370 magicCure.SetMagical();
371 zirconArmor.SetIkari(&magicCure);
372 maxim.SetArmor(&zirconArmor);
374 holyShield.SetName("Holy shield");
375 holyShield.SetMenuIcon(&shieldIcon);
377 lightGuard.SetName("Light guard");
378 lightGuard.SetCost(128);
379 lightGuard.GetTargetingMode().TargetAllAllies(); // actually only targets self
380 lightGuard.SetMagical();
381 holyShield.SetIkari(&lightGuard);
382 maxim.SetShield(&holyShield);
384 legendHelm.SetName("Legend helm");
385 legendHelm.SetMenuIcon(&helmetIcon);
387 boomerang.SetName("Boomerang");
388 boomerang.SetCost(164);
389 boomerang.GetTargetingMode().TargetAllAllies(); // actually only targets self
390 boomerang.SetMagical();
391 legendHelm.SetIkari(&boomerang);
392 maxim.SetHelmet(&legendHelm);
394 sProRing.SetName("S-pro ring");
395 sProRing.SetMenuIcon(&ringIcon);
397 courage.SetName("Courage");
399 courage.GetTargetingMode().TargetMultipleAllies();
400 courage.SetMagical();
401 sProRing.SetIkari(&courage);
402 maxim.SetRing(&sProRing);
404 evilJewel.SetName("Evil jewel");
405 evilJewel.SetMenuIcon(&jewelIcon);
407 gloomy.SetName("Gloomy");
409 gloomy.GetTargetingMode().TargetAllEnemies();
411 evilJewel.SetIkari(&gloomy);
412 maxim.SetJewel(&evilJewel);
415 zircoWhip.SetName("Zirco whip");
416 zircoWhip.SetMenuIcon(&rodIcon);
417 zircoWhip.GetTargetingMode().TargetSingleEnemy();
419 thundershriek.SetName("Thundershriek");
420 thundershriek.SetCost(224);
421 thundershriek.GetTargetingMode().TargetAllEnemies();
422 thundershriek.SetPhysical();
423 zircoWhip.SetIkari(&thundershriek);
424 // selan.SetWeapon(&zircoWhip);
426 zirconPlate.SetName("Zircon plate");
427 zirconPlate.SetMenuIcon(&armorIcon);
429 suddenCure.SetName("Sudden cure");
430 suddenCure.SetCost(96);
431 suddenCure.GetTargetingMode().TargetAllAllies();
432 suddenCure.SetMagical();
433 zirconPlate.SetIkari(&suddenCure);
434 selan.SetArmor(&zirconPlate);
436 zircoGloves.SetName("Zirco gloves");
437 zircoGloves.SetMenuIcon(&shieldIcon);
439 forcefield.SetName("Forcefield");
440 forcefield.SetCost(64);
441 forcefield.GetTargetingMode().TargetAllAllies();
442 forcefield.SetMagical();
443 zircoGloves.SetIkari(&forcefield);
444 selan.SetShield(&zircoGloves);
446 holyCap.SetName("Holy cap");
447 holyCap.SetMenuIcon(&helmetIcon);
449 vulnerable.SetName("Vulnerable");
450 vulnerable.SetCost(196);
451 vulnerable.GetTargetingMode().TargetAllEnemies();
452 vulnerable.SetPhysical();
453 holyCap.SetIkari(&vulnerable);
454 selan.SetHelmet(&holyCap);
456 ghostRing.SetName("Ghost ring");
457 ghostRing.SetMenuIcon(&ringIcon);
459 destroy.SetName("Destroy");
460 destroy.SetCost(128);
461 destroy.GetTargetingMode().TargetMultipleEnemies();
462 destroy.SetMagical();
463 ghostRing.SetIkari(&destroy);
464 selan.SetRing(&ghostRing);
466 eagleRock.SetName("Eagle rock");
467 eagleRock.SetMenuIcon(&jewelIcon);
469 dive.SetName("Dive");
471 dive.GetTargetingMode().TargetSingleEnemy();
473 eagleRock.SetIkari(&dive);
474 selan.SetJewel(&eagleRock);
477 zircoAx.SetName("Zirco ax");
478 zircoAx.SetMenuIcon(&axIcon);
479 zircoAx.GetTargetingMode().TargetSingleEnemy();
481 torrent.SetName("Torrent");
482 torrent.SetCost(224);
483 torrent.GetTargetingMode().TargetAllEnemies();
484 torrent.SetPhysical();
485 zircoAx.SetIkari(&torrent);
486 // guy.SetWeapon(&zircoAx);
487 guy.SetArmor(&zirconArmor);
489 megaShield.SetName("Mega shield");
490 megaShield.SetMenuIcon(&shieldIcon);
492 ironBarrier.SetName("Iron barrier");
493 ironBarrier.SetCost(255);
494 ironBarrier.GetTargetingMode().TargetAllAllies(); // actually only targets self
495 ironBarrier.SetMagical();
496 megaShield.SetIkari(&ironBarrier);
497 guy.SetShield(&megaShield);
499 zircoHelmet.SetName("Zirco helmet");
500 zircoHelmet.SetMenuIcon(&helmetIcon);
502 slow.SetName("Slow");
504 slow.GetTargetingMode().TargetAllEnemies();
506 zircoHelmet.SetIkari(&slow);
507 guy.SetHelmet(&zircoHelmet);
509 powerRing.SetName("Power ring");
510 powerRing.SetMenuIcon(&ringIcon);
512 trick.SetName("Trick");
514 trick.GetTargetingMode().TargetAllEnemies();
516 zircoHelmet.SetIkari(&trick);
517 guy.SetRing(&powerRing);
518 guy.SetJewel(&evilJewel);
520 // NOTE: this is actually Artea equipment
522 lizardBlow.SetName("Lizard blow");
523 lizardBlow.SetMenuIcon(&swordIcon);
524 lizardBlow.GetTargetingMode().TargetSingleEnemy();
526 dragonRush.SetName("Dragon rush");
527 dragonRush.SetCost(164);
528 dragonRush.GetTargetingMode().TargetSingleEnemy();
529 dragonRush.SetPhysical();
530 lizardBlow.SetIkari(&dragonRush);
531 // dekar.SetWeapon(&lizardBlow);
533 holyRobe.SetName("Holy robe");
534 holyRobe.SetMenuIcon(&armorIcon);
536 crisisCure.SetName("Crisis cure");
537 crisisCure.SetCost(164);
538 crisisCure.GetTargetingMode().TargetAllAllies();
539 crisisCure.SetMagical();
540 holyRobe.SetIkari(&crisisCure);
541 dekar.SetArmor(&holyRobe);
542 dekar.SetShield(&zircoGloves);
543 dekar.SetHelmet(&holyCap);
545 rocketRing.SetName("Rocket ring");
546 rocketRing.SetMenuIcon(&ringIcon);
548 fake.SetName("Fake");
550 fake.GetTargetingMode().TargetSingleAlly();
552 rocketRing.SetIkari(&fake);
553 dekar.SetRing(&rocketRing);
555 krakenRock.SetName("Kraken rock");
556 krakenRock.SetMenuIcon(&jewelIcon);
558 tenLegger.SetName("Ten-legger");
559 tenLegger.SetCost(164);
560 tenLegger.GetTargetingMode().TargetAllEnemies();
561 tenLegger.SetPhysical();
562 rocketRing.SetIkari(&tenLegger);
563 dekar.SetJewel(&krakenRock);
565 battleRes.ikariMenuHeadline = "Please choose equipment.";
566 battleRes.noEquipmentText = "No equip";
567 battleRes.ikariMenuPrototype = Menu<const Item *>(&normalFont, &disabledFont, &handCursorSprite, 12, 6, normalFont.CharHeight() / 2, normalFont.CharWidth(), 1, normalFont.CharWidth() * 2, 0, ':', 12, normalFont.CharWidth());
569 battleRes.escapeText = "Escapes.";
571 BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &battleRes));
572 battleState->AddMonster(monster);
573 battleState->AddMonster(monster);
574 battleState->AddMonster(monster);
575 battleState->AddMonster(monster);
576 battleState->AddHero(maxim);
577 battleState->AddHero(selan);
578 battleState->AddHero(guy);
579 battleState->AddHero(dekar);
580 Application app(&screen, battleState);
581 app.Buttons().MapKey(SDLK_w, Input::PAD_UP);
582 app.Buttons().MapKey(SDLK_d, Input::PAD_RIGHT);
583 app.Buttons().MapKey(SDLK_s, Input::PAD_DOWN);
584 app.Buttons().MapKey(SDLK_a, Input::PAD_LEFT);
585 app.Buttons().MapKey(SDLK_RIGHT, Input::ACTION_A);
586 app.Buttons().MapKey(SDLK_DOWN, Input::ACTION_B);
587 app.Buttons().MapKey(SDLK_UP, Input::ACTION_X);
588 app.Buttons().MapKey(SDLK_LEFT, Input::ACTION_Y);
589 app.Buttons().MapKey(SDLK_RETURN, Input::START);
590 app.Buttons().MapKey(SDLK_SPACE, Input::SELECT);
591 app.Buttons().MapKey(SDLK_RSHIFT, Input::SHOULDER_RIGHT);
592 app.Buttons().MapKey(SDLK_LSHIFT, Input::SHOULDER_LEFT);
596 } catch (Parser::Error &e) {
597 cerr << "parsing exception in file " << e.File() << " on line " << e.Line() << ": " << e.what() << endl;
599 } catch (exception &e) {
600 cerr << "exception in main(): " << e.what() << endl;