]> git.localhorst.tv Git - l2e.git/blob - src/main.cpp
made Frame default constructible
[l2e.git] / src / main.cpp
1 /*
2  * main.cpp
3  *
4  *  Created on: Aug 1, 2012
5  *      Author: holy
6  */
7
8 #include "app/Application.h"
9 #include "app/Input.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"
34
35 #include <cstdlib>
36 #include <ctime>
37 #include <exception>
38 #include <iostream>
39 #include <SDL.h>
40 #include <SDL_image.h>
41
42 using app::Application;
43 using app::Input;
44 using battle::BattleState;
45 using battle::Hero;
46 using battle::Monster;
47 using battle::PartyLayout;
48 using battle::Stats;
49 using common::Ikari;
50 using common::Inventory;
51 using common::Item;
52 using common::Spell;
53 using geometry::Vector;
54 using graphics::ComplexAnimation;
55 using graphics::Font;
56 using graphics::Frame;
57 using graphics::Gauge;
58 using graphics::Menu;
59 using graphics::SimpleAnimation;
60 using graphics::Sprite;
61 using loader::Interpreter;
62 using loader::ParsedSource;
63 using loader::Parser;
64 using sdl::InitImage;
65 using sdl::InitScreen;
66 using sdl::InitSDL;
67
68 using std::cerr;
69 using std::cout;
70 using std::endl;
71 using std::exception;
72
73 int main(int argc, char **argv) {
74         const int width = 800;
75         const int height = 480;
76
77         const int framerate = 33;
78
79 //      std::srand(std::time(0));
80
81         try {
82                 InitSDL sdl;
83                 InitImage image(IMG_INIT_PNG);
84
85                 ParsedSource source;
86                 Parser parser("test-data/test.l2s", source);
87                 parser.Parse();
88                 Interpreter intp(source);
89                 intp.ReadSource();
90
91                 InitScreen screen(width, height);
92
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"));
97
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"));
103
104                 battle::Resources battleRes;
105
106                 battleRes.swapCursor = intp.GetSprite("swapCursor");
107                 battleRes.attackIcons = intp.GetSprite("attackIcons");
108                 battleRes.attackChoiceIcons = intp.GetSprite("attackChoiceIcons");
109                 battleRes.moveIcons = intp.GetSprite("moveIcons");
110
111                 SDL_Surface *titleFrameImg(IMG_Load("test-data/title-frame.png"));
112                 Frame titleFrame(titleFrameImg, 16, 16);
113                 battleRes.titleFrame = &titleFrame;
114
115                 SDL_Surface *largeFontImg(IMG_Load("test-data/large-font.png"));
116                 Sprite largeFontSprite(largeFontImg, 16, 32);
117                 Font largeFont(&largeFontSprite, 0, -2);
118                 battleRes.titleFont = &largeFont;
119
120                 battleRes.numberAnimationPrototype = intp.GetAnimation("numberAnimationPrototype");
121                 battleRes.bigNumberSprite = intp.GetSprite("bigNumbers");
122                 battleRes.greenNumberSprite = intp.GetSprite("bigGreenNumbers");
123
124                 battleRes.heroTagLabels = intp.GetSprite("heroTagLabels");
125                 battleRes.levelLabelCol = 0;
126                 battleRes.levelLabelRow = 0;
127                 battleRes.healthLabelCol = 0;
128                 battleRes.healthLabelRow = 1;
129                 battleRes.manaLabelCol = 0;
130                 battleRes.manaLabelRow = 2;
131                 battleRes.moveLabelCol = 0;
132                 battleRes.moveLabelRow = 3;
133                 battleRes.ikariLabelCol = 0;
134                 battleRes.ikariLabelRow = 4;
135
136                 SDL_Surface *numbersImg(IMG_Load("test-data/numbers.png"));
137                 Sprite numbersSprite(numbersImg, 16, 16);
138                 Font heroTagFont(&numbersSprite, 0, -3);
139                 battleRes.heroTagFont = &heroTagFont;
140                 SDL_Surface *tagFramesImg(IMG_Load("test-data/tag-frames.png"));
141                 Frame heroTagFrame(tagFramesImg, 16, 16, 1, 1, 0, 33);
142                 battleRes.heroTagFrame = &heroTagFrame;
143                 Frame activeHeroTagFrame(tagFramesImg, 16, 16);
144                 battleRes.activeHeroTagFrame = &activeHeroTagFrame;
145                 SDL_Surface *smallTagFrameImg(IMG_Load("test-data/small-tag-frame.png"));
146                 Frame smallTagFrame(smallTagFrameImg, 8, 16);
147                 battleRes.smallHeroTagFrame = &smallTagFrame;
148                 Frame lastSmallTagFrame(smallTagFrameImg, 8, 16, 1, 1, 0, 33);
149                 battleRes.lastSmallHeroTagFrame = &lastSmallTagFrame;
150                 battleRes.heroesBgColor = SDL_MapRGB(screen.Screen()->format, 0x18, 0x28, 0x31);
151
152                 SDL_Surface *gauges(IMG_Load("test-data/gauges.png"));
153                 Gauge healthGauge(gauges, 0, 16, 0, 0, 16, 6, 1, 6);
154                 battleRes.healthGauge = &healthGauge;
155                 Gauge manaGauge(gauges, 0, 32, 0, 0, 16, 6, 1, 6);
156                 battleRes.manaGauge = &manaGauge;
157                 Gauge ikariGauge(gauges, 0, 48, 0, 0, 16, 6, 1, 6);
158                 battleRes.ikariGauge = &ikariGauge;
159
160                 SDL_Surface *selectFrameImg(IMG_Load("test-data/select-frame.png"));
161                 Frame selectFrame(selectFrameImg, 16, 16);
162                 battleRes.selectFrame = &selectFrame;
163
164                 SDL_Surface *normalFontImg(IMG_Load("test-data/normal-font.png"));
165                 Sprite normalFontSprite(normalFontImg, 16, 16);
166                 Font normalFont(&normalFontSprite, 0, -2);
167                 battleRes.normalFont = &normalFont;
168
169                 SDL_Surface *disabledFontImg(IMG_Load("test-data/disabled-font.png"));
170                 Sprite disabledFontSprite(disabledFontImg, 16, 16);
171                 Font disabledFont(&disabledFontSprite, 0, -2);
172                 battleRes.disabledFont = &disabledFont;
173
174                 SDL_Surface *handCursorImg(IMG_Load("test-data/cursor-hand.png"));
175                 Sprite handCursorSprite(handCursorImg, 32, 32);
176                 battleRes.menuCursor = &handCursorSprite;
177
178                 SDL_Surface *targetingIconsImg(IMG_Load("test-data/targeting-icons.png"));
179                 Sprite weaponTargetCursor(targetingIconsImg, 32, 32);
180                 Sprite magicTargetCursor(targetingIconsImg, 32, 32, 0, 32);
181                 Sprite itemTargetCursor(targetingIconsImg, 32, 32, 0, 64);
182                 battleRes.weaponTargetCursor = &weaponTargetCursor;
183                 battleRes.magicTargetCursor = &magicTargetCursor;
184                 battleRes.itemTargetCursor = &itemTargetCursor;
185
186                 Spell resetSpell;
187                 resetSpell.SetName("Reset");
188                 maxim.AddSpell(&resetSpell);
189                 Spell strongSpell;
190                 strongSpell.SetName("Strong");
191                 strongSpell.SetCost(3);
192                 strongSpell.SetUsableInBattle();
193                 strongSpell.GetTargetingMode().TargetMultipleAllies();
194                 maxim.AddSpell(&strongSpell);
195                 selan.AddSpell(&strongSpell);
196                 Spell strongerSpell;
197                 strongerSpell.SetName("Stronger");
198                 strongerSpell.SetCost(8);
199                 strongerSpell.SetUsableInBattle();
200                 strongerSpell.GetTargetingMode().TargetMultipleAllies();
201                 maxim.AddSpell(&strongerSpell);
202                 selan.AddSpell(&strongerSpell);
203                 Spell championSpell;
204                 championSpell.SetName("Champion");
205                 championSpell.SetCost(16);
206                 championSpell.SetUsableInBattle();
207                 championSpell.GetTargetingMode().TargetMultipleAllies();
208                 maxim.AddSpell(&championSpell);
209                 selan.AddSpell(&championSpell);
210                 Spell rallySpell;
211                 rallySpell.SetName("Rally");
212                 rallySpell.SetCost(10);
213                 rallySpell.SetUsableInBattle();
214                 rallySpell.GetTargetingMode().TargetMultipleAllies();
215                 maxim.AddSpell(&rallySpell);
216                 selan.AddSpell(&rallySpell);
217                 Spell escapeSpell;
218                 escapeSpell.SetName("Escape");
219                 escapeSpell.SetCost(8);
220                 selan.AddSpell(&escapeSpell);
221                 Spell valorSpell;
222                 valorSpell.SetName("Valor");
223                 valorSpell.SetCost(30);
224                 valorSpell.SetUsableInBattle();
225                 valorSpell.GetTargetingMode().TargetMultipleAllies();
226                 maxim.AddSpell(&valorSpell);
227                 selan.AddSpell(&valorSpell);
228
229                 battleRes.spellMenuHeadline = "Please choose a spell.";
230                 battleRes.spellMenuPrototype = Menu<const Spell *>(&normalFont, &disabledFont, &handCursorSprite, 9, 6, 8, 0, 2, 32, 2, ':');
231
232                 SDL_Surface *itemIcons(IMG_Load("test-data/item-icons.png"));
233                 Sprite potionIcon(itemIcons, 16, 16);
234                 Sprite ballIcon(itemIcons, 16, 16, 0, 16);
235                 Sprite crankIcon(itemIcons, 16, 16, 0, 32);
236                 Sprite spearIcon(itemIcons, 16, 16, 0, 48);
237                 Sprite swordIcon(itemIcons, 16, 16, 0, 64);
238                 Sprite axIcon(itemIcons, 16, 16, 0, 80);
239                 Sprite rodIcon(itemIcons, 16, 16, 0, 96);
240                 Sprite armorIcon(itemIcons, 16, 16, 0, 112);
241                 Sprite shieldIcon(itemIcons, 16, 16, 0, 128);
242                 Sprite helmetIcon(itemIcons, 16, 16, 0, 144);
243                 Sprite ringIcon(itemIcons, 16, 16, 0, 160);
244                 Sprite jewelIcon(itemIcons, 16, 16, 0, 176);
245
246                 battleRes.weaponMenuIcon = &swordIcon;
247                 battleRes.armorMenuIcon = &armorIcon;
248                 battleRes.shieldMenuIcon = &shieldIcon;
249                 battleRes.helmetMenuIcon = &helmetIcon;
250                 battleRes.ringMenuIcon = &ringIcon;
251                 battleRes.jewelMenuIcon = &jewelIcon;
252
253                 Inventory inventory;
254                 Item antidote;
255                 antidote.SetName("Antidote");
256                 antidote.SetMenuIcon(&potionIcon);
257                 antidote.SetUsableInBattle();
258                 antidote.GetTargetingMode().TargetSingleAlly();
259                 inventory.Add(&antidote, 9);
260                 Item magicJar;
261                 magicJar.SetName("Magic jar");
262                 magicJar.SetMenuIcon(&potionIcon);
263                 magicJar.SetUsableInBattle();
264                 magicJar.GetTargetingMode().TargetSingleAlly();
265                 inventory.Add(&magicJar, 4);
266                 Item hiPotion;
267                 hiPotion.SetName("Hi-Potion");
268                 hiPotion.SetMenuIcon(&potionIcon);
269                 hiPotion.SetUsableInBattle();
270                 hiPotion.GetTargetingMode().TargetSingleAlly();
271                 inventory.Add(&hiPotion, 4);
272                 Item powerPotion;
273                 powerPotion.SetName("Power potion");
274                 powerPotion.SetMenuIcon(&potionIcon);
275                 inventory.Add(&powerPotion, 4);
276                 Item escape;
277                 escape.SetName("Escape");
278                 inventory.Add(&escape, 2);
279                 Item sleepBall;
280                 sleepBall.SetName("Sleep ball");
281                 sleepBall.SetMenuIcon(&ballIcon);
282                 sleepBall.SetUsableInBattle();
283                 sleepBall.GetTargetingMode().TargetSingleEnemy();
284                 inventory.Add(&sleepBall, 1);
285                 Item multiBall;
286                 multiBall.SetName("Multi-ball!");
287                 multiBall.SetMenuIcon(&ballIcon);
288                 multiBall.SetUsableInBattle();
289                 multiBall.GetTargetingMode().TargetMultipleEnemies();
290                 inventory.Add(&multiBall, 1);
291                 Item figgoru;
292                 figgoru.SetName("Figgoru");
293                 figgoru.SetMenuIcon(&crankIcon);
294                 figgoru.GetTargetingMode().TargetAllEnemies();
295                 inventory.Add(&figgoru, 1);
296                 battleRes.inventory = &inventory;
297
298                 battleRes.itemMenuHeadline = "Please choose an item.";
299                 battleRes.itemMenuPrototype = Menu<const common::Item *>(&normalFont, &disabledFont, &handCursorSprite, 15, 6, 8, 16, 1, 32, 2, ':');
300
301                 SDL_Surface *swordAttackImg(IMG_Load("test-data/attack-sword.png"));
302                 Sprite swordAttackSprite(swordAttackImg, 96, 96);
303                 SimpleAnimation swordAttackAnimation(&swordAttackSprite, 2 * framerate, 4);
304
305                 Item zircoSword;
306                 zircoSword.SetName("Zirco sword");
307                 zircoSword.SetMenuIcon(&swordIcon);
308                 zircoSword.GetTargetingMode().TargetSingleEnemy();
309                 Ikari firestorm;
310                 firestorm.SetName("Firestorm");
311                 firestorm.SetCost(224);
312                 firestorm.GetTargetingMode().TargetAllEnemies();
313                 firestorm.SetPhysical();
314                 zircoSword.SetIkari(&firestorm);
315                 zircoSword.SetAttackAnimation(&swordAttackAnimation);
316                 maxim.SetWeapon(&zircoSword);
317                 Item zirconArmor;
318                 zirconArmor.SetName("Zircon armor");
319                 zirconArmor.SetMenuIcon(&armorIcon);
320                 Ikari magicCure;
321                 magicCure.SetName("Magic cure");
322                 magicCure.SetCost(128);
323                 magicCure.GetTargetingMode().TargetSingleAlly();
324                 magicCure.SetMagical();
325                 zirconArmor.SetIkari(&magicCure);
326                 maxim.SetArmor(&zirconArmor);
327                 Item holyShield;
328                 holyShield.SetName("Holy shield");
329                 holyShield.SetMenuIcon(&shieldIcon);
330                 Ikari lightGuard;
331                 lightGuard.SetName("Light guard");
332                 lightGuard.SetCost(128);
333                 lightGuard.GetTargetingMode().TargetAllAllies(); // actually only targets self
334                 lightGuard.SetMagical();
335                 holyShield.SetIkari(&lightGuard);
336                 maxim.SetShield(&holyShield);
337                 Item legendHelm;
338                 legendHelm.SetName("Legend helm");
339                 legendHelm.SetMenuIcon(&helmetIcon);
340                 Ikari boomerang;
341                 boomerang.SetName("Boomerang");
342                 boomerang.SetCost(164);
343                 boomerang.GetTargetingMode().TargetAllAllies(); // actually only targets self
344                 boomerang.SetMagical();
345                 legendHelm.SetIkari(&boomerang);
346                 maxim.SetHelmet(&legendHelm);
347                 Item sProRing;
348                 sProRing.SetName("S-pro ring");
349                 sProRing.SetMenuIcon(&ringIcon);
350                 Ikari courage;
351                 courage.SetName("Courage");
352                 courage.SetCost(64);
353                 courage.GetTargetingMode().TargetMultipleAllies();
354                 courage.SetMagical();
355                 sProRing.SetIkari(&courage);
356                 maxim.SetRing(&sProRing);
357                 Item evilJewel;
358                 evilJewel.SetName("Evil jewel");
359                 evilJewel.SetMenuIcon(&jewelIcon);
360                 Ikari gloomy;
361                 gloomy.SetName("Gloomy");
362                 gloomy.SetCost(164);
363                 gloomy.GetTargetingMode().TargetAllEnemies();
364                 gloomy.SetMagical();
365                 evilJewel.SetIkari(&gloomy);
366                 maxim.SetJewel(&evilJewel);
367
368                 Item zircoWhip;
369                 zircoWhip.SetName("Zirco whip");
370                 zircoWhip.SetMenuIcon(&rodIcon);
371                 zircoWhip.GetTargetingMode().TargetSingleEnemy();
372                 Ikari thundershriek;
373                 thundershriek.SetName("Thundershriek");
374                 thundershriek.SetCost(224);
375                 thundershriek.GetTargetingMode().TargetAllEnemies();
376                 thundershriek.SetPhysical();
377                 zircoWhip.SetIkari(&thundershriek);
378 //              selan.SetWeapon(&zircoWhip);
379                 Item zirconPlate;
380                 zirconPlate.SetName("Zircon plate");
381                 zirconPlate.SetMenuIcon(&armorIcon);
382                 Ikari suddenCure;
383                 suddenCure.SetName("Sudden cure");
384                 suddenCure.SetCost(96);
385                 suddenCure.GetTargetingMode().TargetAllAllies();
386                 suddenCure.SetMagical();
387                 zirconPlate.SetIkari(&suddenCure);
388                 selan.SetArmor(&zirconPlate);
389                 Item zircoGloves;
390                 zircoGloves.SetName("Zirco gloves");
391                 zircoGloves.SetMenuIcon(&shieldIcon);
392                 Ikari forcefield;
393                 forcefield.SetName("Forcefield");
394                 forcefield.SetCost(64);
395                 forcefield.GetTargetingMode().TargetAllAllies();
396                 forcefield.SetMagical();
397                 zircoGloves.SetIkari(&forcefield);
398                 selan.SetShield(&zircoGloves);
399                 Item holyCap;
400                 holyCap.SetName("Holy cap");
401                 holyCap.SetMenuIcon(&helmetIcon);
402                 Ikari vulnerable;
403                 vulnerable.SetName("Vulnerable");
404                 vulnerable.SetCost(196);
405                 vulnerable.GetTargetingMode().TargetAllEnemies();
406                 vulnerable.SetPhysical();
407                 holyCap.SetIkari(&vulnerable);
408                 selan.SetHelmet(&holyCap);
409                 Item ghostRing;
410                 ghostRing.SetName("Ghost ring");
411                 ghostRing.SetMenuIcon(&ringIcon);
412                 Ikari destroy;
413                 destroy.SetName("Destroy");
414                 destroy.SetCost(128);
415                 destroy.GetTargetingMode().TargetMultipleEnemies();
416                 destroy.SetMagical();
417                 ghostRing.SetIkari(&destroy);
418                 selan.SetRing(&ghostRing);
419                 Item eagleRock;
420                 eagleRock.SetName("Eagle rock");
421                 eagleRock.SetMenuIcon(&jewelIcon);
422                 Ikari dive;
423                 dive.SetName("Dive");
424                 dive.SetCost(128);
425                 dive.GetTargetingMode().TargetSingleEnemy();
426                 dive.SetPhysical();
427                 eagleRock.SetIkari(&dive);
428                 selan.SetJewel(&eagleRock);
429
430                 Item zircoAx;
431                 zircoAx.SetName("Zirco ax");
432                 zircoAx.SetMenuIcon(&axIcon);
433                 zircoAx.GetTargetingMode().TargetSingleEnemy();
434                 Ikari torrent;
435                 torrent.SetName("Torrent");
436                 torrent.SetCost(224);
437                 torrent.GetTargetingMode().TargetAllEnemies();
438                 torrent.SetPhysical();
439                 zircoAx.SetIkari(&torrent);
440 //              guy.SetWeapon(&zircoAx);
441                 guy.SetArmor(&zirconArmor);
442                 Item megaShield;
443                 megaShield.SetName("Mega shield");
444                 megaShield.SetMenuIcon(&shieldIcon);
445                 Ikari ironBarrier;
446                 ironBarrier.SetName("Iron barrier");
447                 ironBarrier.SetCost(255);
448                 ironBarrier.GetTargetingMode().TargetAllAllies(); // actually only targets self
449                 ironBarrier.SetMagical();
450                 megaShield.SetIkari(&ironBarrier);
451                 guy.SetShield(&megaShield);
452                 Item zircoHelmet;
453                 zircoHelmet.SetName("Zirco helmet");
454                 zircoHelmet.SetMenuIcon(&helmetIcon);
455                 Ikari slow;
456                 slow.SetName("Slow");
457                 slow.SetCost(196);
458                 slow.GetTargetingMode().TargetAllEnemies();
459                 slow.SetPhysical();
460                 zircoHelmet.SetIkari(&slow);
461                 guy.SetHelmet(&zircoHelmet);
462                 Item powerRing;
463                 powerRing.SetName("Power ring");
464                 powerRing.SetMenuIcon(&ringIcon);
465                 Ikari trick;
466                 trick.SetName("Trick");
467                 trick.SetCost(32);
468                 trick.GetTargetingMode().TargetAllEnemies();
469                 trick.SetMagical();
470                 zircoHelmet.SetIkari(&trick);
471                 guy.SetRing(&powerRing);
472                 guy.SetJewel(&evilJewel);
473
474                 // NOTE: this is actually Artea equipment
475                 Item lizardBlow;
476                 lizardBlow.SetName("Lizard blow");
477                 lizardBlow.SetMenuIcon(&swordIcon);
478                 lizardBlow.GetTargetingMode().TargetSingleEnemy();
479                 Ikari dragonRush;
480                 dragonRush.SetName("Dragon rush");
481                 dragonRush.SetCost(164);
482                 dragonRush.GetTargetingMode().TargetSingleEnemy();
483                 dragonRush.SetPhysical();
484                 lizardBlow.SetIkari(&dragonRush);
485 //              dekar.SetWeapon(&lizardBlow);
486                 Item holyRobe;
487                 holyRobe.SetName("Holy robe");
488                 holyRobe.SetMenuIcon(&armorIcon);
489                 Ikari crisisCure;
490                 crisisCure.SetName("Crisis cure");
491                 crisisCure.SetCost(164);
492                 crisisCure.GetTargetingMode().TargetAllAllies();
493                 crisisCure.SetMagical();
494                 holyRobe.SetIkari(&crisisCure);
495                 dekar.SetArmor(&holyRobe);
496                 dekar.SetShield(&zircoGloves);
497                 dekar.SetHelmet(&holyCap);
498                 Item rocketRing;
499                 rocketRing.SetName("Rocket ring");
500                 rocketRing.SetMenuIcon(&ringIcon);
501                 Ikari fake;
502                 fake.SetName("Fake");
503                 fake.SetCost(32);
504                 fake.GetTargetingMode().TargetSingleAlly();
505                 fake.SetMagical();
506                 rocketRing.SetIkari(&fake);
507                 dekar.SetRing(&rocketRing);
508                 Item krakenRock;
509                 krakenRock.SetName("Kraken rock");
510                 krakenRock.SetMenuIcon(&jewelIcon);
511                 Ikari tenLegger;
512                 tenLegger.SetName("Ten-legger");
513                 tenLegger.SetCost(164);
514                 tenLegger.GetTargetingMode().TargetAllEnemies();
515                 tenLegger.SetPhysical();
516                 rocketRing.SetIkari(&tenLegger);
517                 dekar.SetJewel(&krakenRock);
518
519                 battleRes.ikariMenuHeadline = "Please choose equipment.";
520                 battleRes.noEquipmentText = "No equip";
521                 battleRes.ikariMenuPrototype = Menu<const Item *>(&normalFont, &disabledFont, &handCursorSprite, 12, 6, normalFont.CharHeight() / 2, normalFont.CharWidth(), 1, normalFont.CharWidth() * 2, 0, ':', 12, normalFont.CharWidth());
522
523                 battleRes.escapeText = "Escapes.";
524
525                 BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &battleRes));
526                 battleState->AddMonster(monster);
527                 battleState->AddMonster(monster);
528                 battleState->AddMonster(monster);
529                 battleState->AddMonster(monster);
530                 battleState->AddHero(maxim);
531                 battleState->AddHero(selan);
532                 battleState->AddHero(guy);
533                 battleState->AddHero(dekar);
534                 Application app(&screen, battleState);
535                 app.Buttons().MapKey(SDLK_w, Input::PAD_UP);
536                 app.Buttons().MapKey(SDLK_d, Input::PAD_RIGHT);
537                 app.Buttons().MapKey(SDLK_s, Input::PAD_DOWN);
538                 app.Buttons().MapKey(SDLK_a, Input::PAD_LEFT);
539                 app.Buttons().MapKey(SDLK_RIGHT, Input::ACTION_A);
540                 app.Buttons().MapKey(SDLK_DOWN, Input::ACTION_B);
541                 app.Buttons().MapKey(SDLK_UP, Input::ACTION_X);
542                 app.Buttons().MapKey(SDLK_LEFT, Input::ACTION_Y);
543                 app.Buttons().MapKey(SDLK_RETURN, Input::START);
544                 app.Buttons().MapKey(SDLK_SPACE, Input::SELECT);
545                 app.Buttons().MapKey(SDLK_RSHIFT, Input::SHOULDER_RIGHT);
546                 app.Buttons().MapKey(SDLK_LSHIFT, Input::SHOULDER_LEFT);
547                 app.Run();
548
549                 return 0;
550         } catch (Parser::Error &e) {
551                 cerr << "parsing exception in file " << e.File() << " on line " << e.Line() << ": " << e.what() << endl;
552                 return 1;
553         } catch (exception &e) {
554                 cerr << "exception in main(): " << e.what() << endl;
555                 return 1;
556         }
557 }