]> git.localhorst.tv Git - l2e.git/blob - src/main.cpp
909cbd4be04c6292f990c661fd4d5dd265762c09
[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 "common/Ikari.h"
16 #include "common/Inventory.h"
17 #include "common/Item.h"
18 #include "common/Spell.h"
19 #include "geometry/Point.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 "sdl/InitImage.h"
29 #include "sdl/InitScreen.h"
30 #include "sdl/InitSDL.h"
31
32 #include <exception>
33 #include <iostream>
34 #include <SDL.h>
35 #include <SDL_image.h>
36
37 using app::Application;
38 using app::Input;
39 using battle::BattleState;
40 using battle::Hero;
41 using battle::Monster;
42 using battle::PartyLayout;
43 using common::Ikari;
44 using common::Inventory;
45 using common::Item;
46 using common::Spell;
47 using geometry::Point;
48 using geometry::Vector;
49 using graphics::ComplexAnimation;
50 using graphics::Font;
51 using graphics::Frame;
52 using graphics::Gauge;
53 using graphics::Menu;
54 using graphics::SimpleAnimation;
55 using graphics::Sprite;
56 using sdl::InitImage;
57 using sdl::InitScreen;
58 using sdl::InitSDL;
59
60 using std::cerr;
61 using std::cout;
62 using std::endl;
63 using std::exception;
64
65 int main(int argc, char **argv) {
66         const int width = 800;
67         const int height = 480;
68
69         try {
70                 InitSDL sdl;
71                 InitImage image(IMG_INIT_PNG);
72                 InitScreen screen(width, height);
73
74                 // temporary test data
75                 SDL_Surface *bg(IMG_Load("test-data/battle-bg.png"));
76                 PartyLayout monstersLayout;
77                 monstersLayout.AddPosition(Point<Uint8>(88, 88));
78                 monstersLayout.AddPosition(Point<Uint8>(128, 88));
79                 monstersLayout.AddPosition(Point<Uint8>(168, 88));
80                 monstersLayout.AddPosition(Point<Uint8>(208, 88));
81                 PartyLayout heroesLayout;
82                 heroesLayout.AddPosition(Point<Uint8>(48, 136));
83                 heroesLayout.AddPosition(Point<Uint8>(128, 136));
84                 heroesLayout.AddPosition(Point<Uint8>(80, 152));
85                 heroesLayout.AddPosition(Point<Uint8>(160, 152));
86
87                 SDL_Surface *monsterImg(IMG_Load("test-data/monster.png"));
88                 Sprite dummySprite(monsterImg, 64, 64);
89                 Monster monster;
90                 monster.SetName("Monster");
91                 monster.SetSprite(&dummySprite);
92                 monster.SetMaxHealth(10);
93                 monster.SetHealth(10);
94
95                 SDL_Surface *maximImg(IMG_Load("test-data/maxim.png"));
96                 Sprite maximSprite(maximImg, 64, 64);
97                 Hero maxim;
98                 maxim.SetName("Maxim");
99                 maxim.SetLevel(1);
100                 maxim.SetSprite(&maximSprite);
101                 maxim.SetMaxHealth(33);
102                 maxim.SetHealth(33);
103                 maxim.SetMaxMana(20);
104                 maxim.SetMana(20);
105                 maxim.SetIP(0);
106                 ComplexAnimation maximAttackAnimation(&maximSprite, 30);
107                 maximAttackAnimation.AddFrame(1, 0, Vector<int>(2, 0));
108                 maximAttackAnimation.AddFrame(1, 0, Vector<int>(2, -1));
109                 maximAttackAnimation.AddFrames(2, 0, Vector<int>(2, -2), 2);
110                 maximAttackAnimation.AddFrame(2, 0, Vector<int>(4, -2));
111                 maximAttackAnimation.AddFrame(2, 0, Vector<int>(3, -1));
112                 maximAttackAnimation.AddFrames(2, 1, Vector<int>(3, -1), 2);
113                 maximAttackAnimation.AddFrame(2, 1);
114                 maximAttackAnimation.AddFrames(2, 2, Vector<int>(), 2);
115                 maxim.SetAttackAnimation(&maximAttackAnimation);
116                 ComplexAnimation maximSpellAnimation(&maximSprite, 150);
117                 maximSpellAnimation.AddFrames(3, 0, Vector<int>(), 2);
118                 maximSpellAnimation.AddFrame(3, 1);
119                 maxim.SetSpellAnimation(&maximSpellAnimation);
120                 SDL_Surface *maximMeleeImg(IMG_Load("test-data/melee-maxim.png"));
121                 Sprite maximMeleeSprite(maximMeleeImg, 96, 96);
122                 SimpleAnimation maximMeleeAnimation(&maximMeleeSprite, 30, 4);
123                 maxim.SetMeleeAnimation(&maximMeleeAnimation);
124
125                 SDL_Surface *selanImg(IMG_Load("test-data/selan.png"));
126                 Sprite selanSprite(selanImg, 64, 64);
127                 Hero selan;
128                 selan.SetName("Selan");
129                 selan.SetLevel(1);
130                 selan.SetSprite(&selanSprite);
131                 selan.SetMaxHealth(28);
132                 selan.SetHealth(28);
133                 selan.SetMaxMana(23);
134                 selan.SetMana(23);
135                 selan.SetIP(1);
136                 ComplexAnimation selanAttackAnimation(&selanSprite, 30);
137                 selanAttackAnimation.AddFrames(1, 0, Vector<int>(4, 0), 2);
138                 selanAttackAnimation.AddFrame(1, 0, Vector<int>(8, 2));
139                 selanAttackAnimation.AddFrame(2, 0, Vector<int>(10, 4));
140                 selanAttackAnimation.AddFrame(2, 0, Vector<int>(14, 4));
141                 selanAttackAnimation.AddFrames(2, 0, Vector<int>(12, 2), 3);
142                 selanAttackAnimation.AddFrames(2, 1, Vector<int>(14, 2), 2);
143                 selanAttackAnimation.AddFrame(2, 1, Vector<int>(2, 0));
144                 selanAttackAnimation.AddFrame(2, 2, Vector<int>(-2, -4));
145                 selanAttackAnimation.AddFrame(2, 2, Vector<int>(-8, -8));
146                 selanAttackAnimation.AddFrame(2, 2);
147                 selan.SetAttackAnimation(&selanAttackAnimation);
148                 ComplexAnimation selanSpellAnimation(&selanSprite, 30);
149                 selanSpellAnimation.AddFrames(2, 0, Vector<int>(), 3);
150                 selanSpellAnimation.AddFrames(2, 1, Vector<int>(), 2);
151                 selanSpellAnimation.AddFrames(2, 2, Vector<int>(), 3);
152                 selanSpellAnimation.AddFrames(2, 3, Vector<int>(), 2);
153                 selan.SetSpellAnimation(&selanSpellAnimation);
154
155                 SDL_Surface *guyImg(IMG_Load("test-data/guy.png"));
156                 Sprite guySprite(guyImg, 64, 64);
157                 Hero guy;
158                 guy.SetName("Guy");
159                 guy.SetLevel(1);
160                 guy.SetSprite(&guySprite);
161                 guy.SetMaxHealth(38);
162                 guy.SetHealth(38);
163                 guy.SetMaxMana(0);
164                 guy.SetMana(0);
165                 guy.SetIP(254);
166                 ComplexAnimation guyAttackAnimation(&guySprite, 30);
167                 guyAttackAnimation.AddFrames(1, 0, Vector<int>(-4, 0), 2);
168                 guyAttackAnimation.AddFrames(1, 0, Vector<int>(-8, 0), 2);
169                 guyAttackAnimation.AddFrames(2, 0, Vector<int>(-8, 0), 2);
170                 guyAttackAnimation.AddFrame(2, 0, Vector<int>(-4, 0));
171                 guyAttackAnimation.AddFrames(2, 0, Vector<int>(), 2);
172                 guyAttackAnimation.AddFrame(2, 1);
173                 guyAttackAnimation.AddFrame(2, 1, Vector<int>(4, 0));
174                 guyAttackAnimation.AddFrame(2, 1, Vector<int>(10, 0));
175                 guyAttackAnimation.AddFrame(2, 2, Vector<int>(10, 0));
176                 guyAttackAnimation.AddFrame(2, 2);
177                 guy.SetAttackAnimation(&guyAttackAnimation);
178
179                 SDL_Surface *dekarImg(IMG_Load("test-data/dekar.png"));
180                 Sprite dekarSprite(dekarImg, 64, 64);
181                 Hero dekar;
182                 dekar.SetName("Dekar");
183                 dekar.SetLevel(1);
184                 dekar.SetSprite(&dekarSprite);
185                 dekar.SetMaxHealth(38);
186                 dekar.SetHealth(38);
187                 dekar.SetMaxMana(0);
188                 dekar.SetMana(0);
189                 dekar.SetIP(255);
190                 ComplexAnimation dekarAttackAnimation(&dekarSprite, 30);
191                 dekarAttackAnimation.AddFrame(1, 0, Vector<int>(4, 0));
192                 dekarAttackAnimation.AddFrame(1, 0, Vector<int>(8, 2));
193                 dekarAttackAnimation.AddFrame(2, 0, Vector<int>(12, 4));
194                 dekarAttackAnimation.AddFrame(2, 0, Vector<int>(16, 4));
195                 dekarAttackAnimation.AddFrames(2, 0, Vector<int>(10, 2), 4);
196                 dekarAttackAnimation.AddFrame(2, 1, Vector<int>(6, 2));
197                 dekarAttackAnimation.AddFrame(2, 1, Vector<int>());
198                 dekarAttackAnimation.AddFrame(2, 2, Vector<int>(-2, 0));
199                 dekarAttackAnimation.AddFrames(2, 2, Vector<int>(0, 0), 3);
200                 dekar.SetAttackAnimation(&dekarAttackAnimation);
201                 ComplexAnimation dekarSpellAnimation(&dekarSprite, 30);
202                 dekarSpellAnimation.AddFrames(2, 0, Vector<int>(), 6);
203                 dekarSpellAnimation.AddFrames(2, 1, Vector<int>(), 2);
204                 dekarSpellAnimation.AddFrames(2, 2, Vector<int>(), 3);
205                 dekar.SetSpellAnimation(&dekarSpellAnimation);
206
207                 battle::Resources battleRes;
208
209                 SDL_Surface *swapCursorImg(IMG_Load("test-data/swap-cursor.png"));
210                 Sprite swapCursorSprite(swapCursorImg, 32, 32);
211                 battleRes.swapCursor = &swapCursorSprite;
212                 SDL_Surface *attackIconsImg(IMG_Load("test-data/attack-type-icons.png"));
213                 Sprite attackIconsSprite(attackIconsImg, 32, 32);
214                 battleRes.attackIcons = &attackIconsSprite;
215                 SDL_Surface *attackChoiceIconsImg(IMG_Load("test-data/attack-choice-icons.png"));
216                 Sprite attackChoiceIconsSprite(attackChoiceIconsImg, 16, 16);
217                 battleRes.attackChoiceIcons = &attackChoiceIconsSprite;
218                 SDL_Surface *moveIconsImg(IMG_Load("test-data/move-icons.png"));
219                 Sprite moveIconsSprite(moveIconsImg, 32, 32);
220                 battleRes.moveIcons = &moveIconsSprite;
221
222                 SDL_Surface *titleFrameImg(IMG_Load("test-data/title-frame.png"));
223                 Frame titleFrame(titleFrameImg, 16, 16);
224                 battleRes.titleFrame = &titleFrame;
225
226                 SDL_Surface *largeFontImg(IMG_Load("test-data/large-font.png"));
227                 Sprite largeFontSprite(largeFontImg, 16, 32);
228                 Font largeFont(&largeFontSprite, 0, -2);
229                 battleRes.titleFont = &largeFont;
230
231                 battleRes.numberAnimationPrototype = ComplexAnimation(0, 30);
232                 battleRes.numberAnimationPrototype.AddFrame(0, 0);
233                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -26));
234                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -42));
235                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -48));
236                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -42));
237                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -26));
238                 battleRes.numberAnimationPrototype.AddFrame(0, 0);
239                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
240                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -20));
241                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -24));
242                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -20));
243                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
244                 battleRes.numberAnimationPrototype.AddFrame(0, 0);
245                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -6));
246                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -10));
247                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
248                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -10));
249                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -6));
250                 battleRes.numberAnimationPrototype.AddFrames(0, 0, Vector<int>(), 14);
251                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -36));
252                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -32));
253                 battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -18));
254
255                 SDL_Surface *bigNumbersImg(IMG_Load("test-data/big-numbers.png"));
256                 Sprite bigNumbersSprite(bigNumbersImg, 16, 32);
257                 battleRes.bigNumberSprite = &bigNumbersSprite;
258                 SDL_Surface *bigGreenNumbersImg(IMG_Load("test-data/big-green-numbers.png"));
259                 Sprite bigGreenNumbersSprite(bigGreenNumbersImg, 16, 32);
260                 battleRes.greenNumberSprite = &bigGreenNumbersSprite;
261
262                 SDL_Surface *heroTagImg(IMG_Load("test-data/hero-tag-sprites.png"));
263                 Sprite heroTagSprite(heroTagImg, 32, 16);
264                 battleRes.heroTagLabels = &heroTagSprite;
265                 battleRes.levelLabelCol = 0;
266                 battleRes.levelLabelRow = 0;
267                 battleRes.healthLabelCol = 0;
268                 battleRes.healthLabelRow = 1;
269                 battleRes.manaLabelCol = 0;
270                 battleRes.manaLabelRow = 2;
271                 battleRes.moveLabelCol = 0;
272                 battleRes.moveLabelRow = 3;
273                 battleRes.ikariLabelCol = 0;
274                 battleRes.ikariLabelRow = 4;
275
276                 SDL_Surface *numbersImg(IMG_Load("test-data/numbers.png"));
277                 Sprite numbersSprite(numbersImg, 16, 16);
278                 Font heroTagFont(&numbersSprite, 0, -3);
279                 battleRes.heroTagFont = &heroTagFont;
280                 SDL_Surface *tagFramesImg(IMG_Load("test-data/tag-frames.png"));
281                 Frame heroTagFrame(tagFramesImg, 16, 16, 1, 1, 0, 33);
282                 battleRes.heroTagFrame = &heroTagFrame;
283                 Frame activeHeroTagFrame(tagFramesImg, 16, 16);
284                 battleRes.activeHeroTagFrame = &activeHeroTagFrame;
285                 SDL_Surface *smallTagFrameImg(IMG_Load("test-data/small-tag-frame.png"));
286                 Frame smallTagFrame(smallTagFrameImg, 8, 16);
287                 battleRes.smallHeroTagFrame = &smallTagFrame;
288                 Frame lastSmallTagFrame(smallTagFrameImg, 8, 16, 1, 1, 0, 33);
289                 battleRes.lastSmallHeroTagFrame = &lastSmallTagFrame;
290                 battleRes.heroesBgColor = SDL_MapRGB(screen.Screen()->format, 0x18, 0x28, 0x31);
291
292                 SDL_Surface *gauges(IMG_Load("test-data/gauges.png"));
293                 Gauge healthGauge(gauges, 0, 16, 0, 0, 16, 6, 1, 6);
294                 battleRes.healthGauge = &healthGauge;
295                 Gauge manaGauge(gauges, 0, 32, 0, 0, 16, 6, 1, 6);
296                 battleRes.manaGauge = &manaGauge;
297                 Gauge ikariGauge(gauges, 0, 48, 0, 0, 16, 6, 1, 6);
298                 battleRes.ikariGauge = &ikariGauge;
299
300                 SDL_Surface *selectFrameImg(IMG_Load("test-data/select-frame.png"));
301                 Frame selectFrame(selectFrameImg, 16, 16);
302                 battleRes.selectFrame = &selectFrame;
303
304                 SDL_Surface *normalFontImg(IMG_Load("test-data/normal-font.png"));
305                 Sprite normalFontSprite(normalFontImg, 16, 16);
306                 Font normalFont(&normalFontSprite, 0, -2);
307                 battleRes.normalFont = &normalFont;
308
309                 SDL_Surface *disabledFontImg(IMG_Load("test-data/disabled-font.png"));
310                 Sprite disabledFontSprite(disabledFontImg, 16, 16);
311                 Font disabledFont(&disabledFontSprite, 0, -2);
312                 battleRes.disabledFont = &disabledFont;
313
314                 SDL_Surface *handCursorImg(IMG_Load("test-data/cursor-hand.png"));
315                 Sprite handCursorSprite(handCursorImg, 32, 32);
316                 battleRes.menuCursor = &handCursorSprite;
317
318                 SDL_Surface *targetingIconsImg(IMG_Load("test-data/targeting-icons.png"));
319                 Sprite weaponTargetCursor(targetingIconsImg, 32, 32);
320                 Sprite magicTargetCursor(targetingIconsImg, 32, 32, 0, 32);
321                 Sprite itemTargetCursor(targetingIconsImg, 32, 32, 0, 64);
322                 battleRes.weaponTargetCursor = &weaponTargetCursor;
323                 // TODO: add image for magic targeting cursor
324                 battleRes.magicTargetCursor = &magicTargetCursor;
325                 // TODO: add image for item targeting cursor
326                 battleRes.itemTargetCursor = &itemTargetCursor;
327
328                 Spell resetSpell;
329                 resetSpell.SetName("Reset");
330                 maxim.AddSpell(&resetSpell);
331                 Spell strongSpell;
332                 strongSpell.SetName("Strong");
333                 strongSpell.SetCost(3);
334                 strongSpell.SetUsableInBattle();
335                 strongSpell.GetTargetingMode().TargetMultipleAllies();
336                 maxim.AddSpell(&strongSpell);
337                 selan.AddSpell(&strongSpell);
338                 Spell strongerSpell;
339                 strongerSpell.SetName("Stronger");
340                 strongerSpell.SetCost(8);
341                 strongerSpell.SetUsableInBattle();
342                 strongerSpell.GetTargetingMode().TargetMultipleAllies();
343                 maxim.AddSpell(&strongerSpell);
344                 selan.AddSpell(&strongerSpell);
345                 Spell championSpell;
346                 championSpell.SetName("Champion");
347                 championSpell.SetCost(16);
348                 championSpell.SetUsableInBattle();
349                 championSpell.GetTargetingMode().TargetMultipleAllies();
350                 maxim.AddSpell(&championSpell);
351                 selan.AddSpell(&championSpell);
352                 Spell rallySpell;
353                 rallySpell.SetName("Rally");
354                 rallySpell.SetCost(10);
355                 rallySpell.SetUsableInBattle();
356                 rallySpell.GetTargetingMode().TargetMultipleAllies();
357                 maxim.AddSpell(&rallySpell);
358                 selan.AddSpell(&rallySpell);
359                 Spell escapeSpell;
360                 escapeSpell.SetName("Escape");
361                 escapeSpell.SetCost(8);
362                 selan.AddSpell(&escapeSpell);
363                 Spell valorSpell;
364                 valorSpell.SetName("Valor");
365                 valorSpell.SetCost(30);
366                 valorSpell.SetUsableInBattle();
367                 valorSpell.GetTargetingMode().TargetMultipleAllies();
368                 maxim.AddSpell(&valorSpell);
369                 selan.AddSpell(&valorSpell);
370
371                 battleRes.spellMenuHeadline = "Please choose a spell.";
372                 battleRes.spellMenuPrototype = Menu<const Spell *>(&normalFont, &disabledFont, &handCursorSprite, 9, 6, 8, 0, 2, 32, 2, ':');
373
374                 SDL_Surface *itemIcons(IMG_Load("test-data/item-icons.png"));
375                 Sprite potionIcon(itemIcons, 16, 16);
376                 Sprite ballIcon(itemIcons, 16, 16, 0, 16);
377                 Sprite crankIcon(itemIcons, 16, 16, 0, 32);
378                 Sprite spearIcon(itemIcons, 16, 16, 0, 48);
379                 Sprite swordIcon(itemIcons, 16, 16, 0, 64);
380                 Sprite axIcon(itemIcons, 16, 16, 0, 80);
381                 Sprite rodIcon(itemIcons, 16, 16, 0, 96);
382                 Sprite armorIcon(itemIcons, 16, 16, 0, 112);
383                 Sprite shieldIcon(itemIcons, 16, 16, 0, 128);
384                 Sprite helmetIcon(itemIcons, 16, 16, 0, 144);
385                 Sprite ringIcon(itemIcons, 16, 16, 0, 160);
386                 Sprite jewelIcon(itemIcons, 16, 16, 0, 176);
387
388                 battleRes.weaponMenuIcon = &swordIcon;
389                 battleRes.armorMenuIcon = &armorIcon;
390                 battleRes.shieldMenuIcon = &shieldIcon;
391                 battleRes.helmetMenuIcon = &helmetIcon;
392                 battleRes.ringMenuIcon = &ringIcon;
393                 battleRes.jewelMenuIcon = &jewelIcon;
394
395                 Inventory inventory;
396                 Item antidote;
397                 antidote.SetName("Antidote");
398                 antidote.SetMenuIcon(&potionIcon);
399                 antidote.SetUsableInBattle();
400                 antidote.GetTargetingMode().TargetSingleAlly();
401                 inventory.Add(&antidote, 9);
402                 Item magicJar;
403                 magicJar.SetName("Magic jar");
404                 magicJar.SetMenuIcon(&potionIcon);
405                 magicJar.SetUsableInBattle();
406                 magicJar.GetTargetingMode().TargetSingleAlly();
407                 inventory.Add(&magicJar, 4);
408                 Item hiPotion;
409                 hiPotion.SetName("Hi-Potion");
410                 hiPotion.SetMenuIcon(&potionIcon);
411                 hiPotion.SetUsableInBattle();
412                 hiPotion.GetTargetingMode().TargetSingleAlly();
413                 inventory.Add(&hiPotion, 4);
414                 Item powerPotion;
415                 powerPotion.SetName("Power potion");
416                 powerPotion.SetMenuIcon(&potionIcon);
417                 inventory.Add(&powerPotion, 4);
418                 Item escape;
419                 escape.SetName("Escape");
420                 inventory.Add(&escape, 2);
421                 Item sleepBall;
422                 sleepBall.SetName("Sleep ball");
423                 sleepBall.SetMenuIcon(&ballIcon);
424                 sleepBall.SetUsableInBattle();
425                 sleepBall.GetTargetingMode().TargetSingleEnemy();
426                 inventory.Add(&sleepBall, 1);
427                 Item multiBall;
428                 multiBall.SetName("Multi-ball!");
429                 multiBall.SetMenuIcon(&ballIcon);
430                 multiBall.SetUsableInBattle();
431                 multiBall.GetTargetingMode().TargetMultipleEnemies();
432                 inventory.Add(&multiBall, 1);
433                 Item figgoru;
434                 figgoru.SetName("Figgoru");
435                 figgoru.SetMenuIcon(&crankIcon);
436                 figgoru.GetTargetingMode().TargetAllEnemies();
437                 inventory.Add(&figgoru, 1);
438                 battleRes.inventory = &inventory;
439
440                 battleRes.itemMenuHeadline = "Please choose an item.";
441                 battleRes.itemMenuPrototype = Menu<const common::Item *>(&normalFont, &disabledFont, &handCursorSprite, 15, 6, 8, 16, 1, 32, 2, ':');
442
443                 Item zircoSword;
444                 zircoSword.SetName("Zirco sword");
445                 zircoSword.SetMenuIcon(&swordIcon);
446                 Ikari firestorm;
447                 firestorm.SetName("Firestorm");
448                 firestorm.SetCost(224);
449                 firestorm.GetTargetingMode().TargetAllEnemies();
450                 firestorm.SetPhysical();
451                 zircoSword.SetIkari(&firestorm);
452 //              maxim.SetWeapon(&zircoSword);
453                 Item zirconArmor;
454                 zirconArmor.SetName("Zircon armor");
455                 zirconArmor.SetMenuIcon(&armorIcon);
456                 Ikari magicCure;
457                 magicCure.SetName("Magic cure");
458                 magicCure.SetCost(128);
459                 magicCure.GetTargetingMode().TargetSingleAlly();
460                 magicCure.SetMagical();
461                 zirconArmor.SetIkari(&magicCure);
462                 maxim.SetArmor(&zirconArmor);
463                 Item holyShield;
464                 holyShield.SetName("Holy shield");
465                 holyShield.SetMenuIcon(&shieldIcon);
466                 Ikari lightGuard;
467                 lightGuard.SetName("Light guard");
468                 lightGuard.SetCost(128);
469                 lightGuard.GetTargetingMode().TargetAllAllies(); // FIXME: actually only targets self
470                 lightGuard.SetMagical();
471                 holyShield.SetIkari(&lightGuard);
472                 maxim.SetShield(&holyShield);
473                 Item legendHelm;
474                 legendHelm.SetName("Legend helm");
475                 legendHelm.SetMenuIcon(&helmetIcon);
476                 Ikari boomerang;
477                 boomerang.SetName("Boomerang");
478                 boomerang.SetCost(164);
479                 boomerang.GetTargetingMode().TargetAllAllies(); // FIXME: actually only targets self
480                 boomerang.SetMagical();
481                 legendHelm.SetIkari(&boomerang);
482                 maxim.SetHelmet(&legendHelm);
483                 Item sProRing;
484                 sProRing.SetName("S-pro ring");
485                 sProRing.SetMenuIcon(&ringIcon);
486                 Ikari courage;
487                 courage.SetName("Courage");
488                 courage.SetCost(64);
489                 courage.GetTargetingMode().TargetMultipleAllies();
490                 courage.SetMagical();
491                 sProRing.SetIkari(&courage);
492                 maxim.SetRing(&sProRing);
493                 Item evilJewel;
494                 evilJewel.SetName("Evil jewel");
495                 evilJewel.SetMenuIcon(&jewelIcon);
496                 Ikari gloomy;
497                 gloomy.SetName("Gloomy");
498                 gloomy.SetCost(164);
499                 gloomy.GetTargetingMode().TargetAllEnemies();
500                 gloomy.SetMagical();
501                 evilJewel.SetIkari(&gloomy);
502                 maxim.SetJewel(&evilJewel);
503
504                 Item zircoWhip;
505                 zircoWhip.SetName("Zirco whip");
506                 zircoWhip.SetMenuIcon(&rodIcon);
507                 Ikari thundershriek;
508                 thundershriek.SetName("Thundershriek");
509                 thundershriek.SetCost(224);
510                 thundershriek.GetTargetingMode().TargetAllEnemies();
511                 thundershriek.SetPhysical();
512                 zircoWhip.SetIkari(&thundershriek);
513                 selan.SetWeapon(&zircoWhip);
514                 Item zirconPlate;
515                 zirconPlate.SetName("Zircon plate");
516                 zirconPlate.SetMenuIcon(&armorIcon);
517                 Ikari suddenCure;
518                 suddenCure.SetName("Sudden cure");
519                 suddenCure.SetCost(96);
520                 suddenCure.GetTargetingMode().TargetAllAllies();
521                 suddenCure.SetMagical();
522                 zirconPlate.SetIkari(&suddenCure);
523                 selan.SetArmor(&zirconPlate);
524                 Item zircoGloves;
525                 zircoGloves.SetName("Zirco gloves");
526                 zircoGloves.SetMenuIcon(&shieldIcon);
527                 Ikari forcefield;
528                 forcefield.SetName("Forcefield");
529                 forcefield.SetCost(64);
530                 forcefield.GetTargetingMode().TargetAllAllies();
531                 forcefield.SetMagical();
532                 zircoGloves.SetIkari(&forcefield);
533                 selan.SetShield(&zircoGloves);
534                 Item holyCap;
535                 holyCap.SetName("Holy cap");
536                 holyCap.SetMenuIcon(&helmetIcon);
537                 Ikari vulnerable;
538                 vulnerable.SetName("Vulnerable");
539                 vulnerable.SetCost(196);
540                 vulnerable.GetTargetingMode().TargetAllEnemies();
541                 vulnerable.SetPhysical();
542                 holyCap.SetIkari(&vulnerable);
543                 selan.SetHelmet(&holyCap);
544                 Item ghostRing;
545                 ghostRing.SetName("Ghost ring");
546                 ghostRing.SetMenuIcon(&ringIcon);
547                 Ikari destroy;
548                 destroy.SetName("Destroy");
549                 destroy.SetCost(128);
550                 destroy.GetTargetingMode().TargetMultipleEnemies();
551                 destroy.SetMagical();
552                 ghostRing.SetIkari(&destroy);
553                 selan.SetRing(&ghostRing);
554                 Item eagleRock;
555                 eagleRock.SetName("Eagle rock");
556                 eagleRock.SetMenuIcon(&jewelIcon);
557                 Ikari dive;
558                 dive.SetName("Dive");
559                 dive.SetCost(128);
560                 dive.GetTargetingMode().TargetSingleEnemy();
561                 dive.SetPhysical();
562                 eagleRock.SetIkari(&dive);
563                 selan.SetJewel(&eagleRock);
564
565                 Item zircoAx;
566                 zircoAx.SetName("Zirco ax");
567                 zircoAx.SetMenuIcon(&axIcon);
568                 Ikari torrent;
569                 torrent.SetName("Torrent");
570                 torrent.SetCost(224);
571                 torrent.GetTargetingMode().TargetAllEnemies();
572                 torrent.SetPhysical();
573                 zircoAx.SetIkari(&torrent);
574                 guy.SetWeapon(&zircoAx);
575                 guy.SetArmor(&zirconArmor);
576                 Item megaShield;
577                 megaShield.SetName("Mega shield");
578                 megaShield.SetMenuIcon(&shieldIcon);
579                 Ikari ironBarrier;
580                 ironBarrier.SetName("Iron barrier");
581                 ironBarrier.SetCost(255);
582                 ironBarrier.GetTargetingMode().TargetAllAllies(); // FIXME: actually only targets self
583                 ironBarrier.SetMagical();
584                 megaShield.SetIkari(&ironBarrier);
585                 guy.SetShield(&megaShield);
586                 Item zircoHelmet;
587                 zircoHelmet.SetName("Zirco helmet");
588                 zircoHelmet.SetMenuIcon(&helmetIcon);
589                 Ikari slow;
590                 slow.SetName("Slow");
591                 slow.SetCost(196);
592                 slow.GetTargetingMode().TargetAllEnemies();
593                 slow.SetPhysical();
594                 zircoHelmet.SetIkari(&slow);
595                 guy.SetHelmet(&zircoHelmet);
596                 Item powerRing;
597                 powerRing.SetName("Power ring");
598                 powerRing.SetMenuIcon(&ringIcon);
599                 Ikari trick;
600                 trick.SetName("Trick");
601                 trick.SetCost(32);
602                 trick.GetTargetingMode().TargetAllEnemies();
603                 trick.SetMagical();
604                 zircoHelmet.SetIkari(&trick);
605                 guy.SetRing(&powerRing);
606                 guy.SetJewel(&evilJewel);
607
608                 // NOTE: this is actually Artea equipment
609                 Item lizardBlow;
610                 lizardBlow.SetName("Lizard blow");
611                 lizardBlow.SetMenuIcon(&swordIcon);
612                 Ikari dragonRush;
613                 dragonRush.SetName("Dragon rush");
614                 dragonRush.SetCost(164);
615                 dragonRush.GetTargetingMode().TargetSingleEnemy();
616                 dragonRush.SetPhysical();
617                 lizardBlow.SetIkari(&dragonRush);
618                 dekar.SetWeapon(&lizardBlow);
619                 Item holyRobe;
620                 holyRobe.SetName("Holy robe");
621                 holyRobe.SetMenuIcon(&armorIcon);
622                 Ikari crisisCure;
623                 crisisCure.SetName("Crisis cure");
624                 crisisCure.SetCost(164);
625                 crisisCure.GetTargetingMode().TargetAllAllies();
626                 crisisCure.SetMagical();
627                 holyRobe.SetIkari(&crisisCure);
628                 dekar.SetArmor(&holyRobe);
629                 dekar.SetShield(&zircoGloves);
630                 dekar.SetHelmet(&holyCap);
631                 Item rocketRing;
632                 rocketRing.SetName("Rocket ring");
633                 rocketRing.SetMenuIcon(&ringIcon);
634                 Ikari fake;
635                 fake.SetName("Fake");
636                 fake.SetCost(32);
637                 fake.GetTargetingMode().TargetSingleAlly();
638                 fake.SetMagical();
639                 rocketRing.SetIkari(&fake);
640                 dekar.SetRing(&rocketRing);
641                 Item krakenRock;
642                 krakenRock.SetName("Kraken rock");
643                 krakenRock.SetMenuIcon(&jewelIcon);
644                 Ikari tenLegger;
645                 tenLegger.SetName("Ten-legger");
646                 tenLegger.SetCost(164);
647                 tenLegger.GetTargetingMode().TargetAllEnemies();
648                 tenLegger.SetPhysical();
649                 rocketRing.SetIkari(&tenLegger);
650                 dekar.SetJewel(&krakenRock);
651
652                 battleRes.ikariMenuHeadline = "Please choose equipment.";
653                 battleRes.noEquipmentText = "No equip";
654                 battleRes.ikariMenuPrototype = Menu<const Item *>(&normalFont, &disabledFont, &handCursorSprite, 12, 6, normalFont.CharHeight() / 2, normalFont.CharWidth(), 1, normalFont.CharWidth() * 2, 0, ':', 12, normalFont.CharWidth());
655
656                 battleRes.escapeText = "Escapes.";
657
658                 BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &battleRes));
659                 battleState->AddMonster(monster);
660                 battleState->AddMonster(monster);
661                 battleState->AddMonster(monster);
662                 battleState->AddMonster(monster);
663                 battleState->AddHero(maxim);
664                 battleState->AddHero(selan);
665                 battleState->AddHero(guy);
666                 battleState->AddHero(dekar);
667                 Application app(&screen, battleState);
668                 app.Buttons().MapKey(SDLK_w, Input::PAD_UP);
669                 app.Buttons().MapKey(SDLK_d, Input::PAD_RIGHT);
670                 app.Buttons().MapKey(SDLK_s, Input::PAD_DOWN);
671                 app.Buttons().MapKey(SDLK_a, Input::PAD_LEFT);
672                 app.Buttons().MapKey(SDLK_RIGHT, Input::ACTION_A);
673                 app.Buttons().MapKey(SDLK_DOWN, Input::ACTION_B);
674                 app.Buttons().MapKey(SDLK_UP, Input::ACTION_X);
675                 app.Buttons().MapKey(SDLK_LEFT, Input::ACTION_Y);
676                 app.Buttons().MapKey(SDLK_RETURN, Input::START);
677                 app.Buttons().MapKey(SDLK_SPACE, Input::SELECT);
678                 app.Buttons().MapKey(SDLK_RSHIFT, Input::SHOULDER_RIGHT);
679                 app.Buttons().MapKey(SDLK_LSHIFT, Input::SHOULDER_LEFT);
680                 app.Run();
681
682                 return 0;
683         } catch (exception &e) {
684                 cerr << "exception in main(): " << e.what() << endl;
685                 return 1;
686         }
687 }