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