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