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