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