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