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