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