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