]> git.localhorst.tv Git - l2e.git/blob - src/main.cpp
fix monster attack animation frame offsets
[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>(0, 16));
103                 monsterAttackAnimation.AddFrame(0, 0, Vector<int>(0, 16));
104                 monsterAttackAnimation.AddFrame(0, 1, Vector<int>(0, 16));
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                 ComplexAnimation numberAnimationPrototype(0, framerate);
267                 numberAnimationPrototype.AddFrame(0, 0);
268                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -26));
269                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -42));
270                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -48));
271                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -42));
272                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -26));
273                 numberAnimationPrototype.AddFrame(0, 0);
274                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
275                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -20));
276                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -24));
277                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -20));
278                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
279                 numberAnimationPrototype.AddFrame(0, 0);
280                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -6));
281                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -10));
282                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
283                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -10));
284                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -6));
285                 numberAnimationPrototype.AddFrames(0, 0, Vector<int>(), 14);
286                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -36));
287                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -32));
288                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -18));
289                 battleRes.numberAnimationPrototype = &numberAnimationPrototype;
290
291                 SDL_Surface *bigNumbersImg(IMG_Load("test-data/big-numbers.png"));
292                 Sprite bigNumbersSprite(bigNumbersImg, 16, 32);
293                 battleRes.bigNumberSprite = &bigNumbersSprite;
294                 SDL_Surface *bigGreenNumbersImg(IMG_Load("test-data/big-green-numbers.png"));
295                 Sprite bigGreenNumbersSprite(bigGreenNumbersImg, 16, 32);
296                 battleRes.greenNumberSprite = &bigGreenNumbersSprite;
297
298                 SDL_Surface *heroTagImg(IMG_Load("test-data/hero-tag-sprites.png"));
299                 Sprite heroTagSprite(heroTagImg, 32, 16);
300                 battleRes.heroTagLabels = &heroTagSprite;
301                 battleRes.levelLabelCol = 0;
302                 battleRes.levelLabelRow = 0;
303                 battleRes.healthLabelCol = 0;
304                 battleRes.healthLabelRow = 1;
305                 battleRes.manaLabelCol = 0;
306                 battleRes.manaLabelRow = 2;
307                 battleRes.moveLabelCol = 0;
308                 battleRes.moveLabelRow = 3;
309                 battleRes.ikariLabelCol = 0;
310                 battleRes.ikariLabelRow = 4;
311
312                 SDL_Surface *numbersImg(IMG_Load("test-data/numbers.png"));
313                 Sprite numbersSprite(numbersImg, 16, 16);
314                 Font heroTagFont(&numbersSprite, 0, -3);
315                 battleRes.heroTagFont = &heroTagFont;
316                 SDL_Surface *tagFramesImg(IMG_Load("test-data/tag-frames.png"));
317                 Frame heroTagFrame(tagFramesImg, 16, 16, 1, 1, 0, 33);
318                 battleRes.heroTagFrame = &heroTagFrame;
319                 Frame activeHeroTagFrame(tagFramesImg, 16, 16);
320                 battleRes.activeHeroTagFrame = &activeHeroTagFrame;
321                 SDL_Surface *smallTagFrameImg(IMG_Load("test-data/small-tag-frame.png"));
322                 Frame smallTagFrame(smallTagFrameImg, 8, 16);
323                 battleRes.smallHeroTagFrame = &smallTagFrame;
324                 Frame lastSmallTagFrame(smallTagFrameImg, 8, 16, 1, 1, 0, 33);
325                 battleRes.lastSmallHeroTagFrame = &lastSmallTagFrame;
326                 battleRes.heroesBgColor = SDL_MapRGB(screen.Screen()->format, 0x18, 0x28, 0x31);
327
328                 SDL_Surface *gauges(IMG_Load("test-data/gauges.png"));
329                 Gauge healthGauge(gauges, 0, 16, 0, 0, 16, 6, 1, 6);
330                 battleRes.healthGauge = &healthGauge;
331                 Gauge manaGauge(gauges, 0, 32, 0, 0, 16, 6, 1, 6);
332                 battleRes.manaGauge = &manaGauge;
333                 Gauge ikariGauge(gauges, 0, 48, 0, 0, 16, 6, 1, 6);
334                 battleRes.ikariGauge = &ikariGauge;
335
336                 SDL_Surface *selectFrameImg(IMG_Load("test-data/select-frame.png"));
337                 Frame selectFrame(selectFrameImg, 16, 16);
338                 battleRes.selectFrame = &selectFrame;
339
340                 SDL_Surface *normalFontImg(IMG_Load("test-data/normal-font.png"));
341                 Sprite normalFontSprite(normalFontImg, 16, 16);
342                 Font normalFont(&normalFontSprite, 0, -2);
343                 battleRes.normalFont = &normalFont;
344
345                 SDL_Surface *disabledFontImg(IMG_Load("test-data/disabled-font.png"));
346                 Sprite disabledFontSprite(disabledFontImg, 16, 16);
347                 Font disabledFont(&disabledFontSprite, 0, -2);
348                 battleRes.disabledFont = &disabledFont;
349
350                 SDL_Surface *handCursorImg(IMG_Load("test-data/cursor-hand.png"));
351                 Sprite handCursorSprite(handCursorImg, 32, 32);
352                 battleRes.menuCursor = &handCursorSprite;
353
354                 SDL_Surface *targetingIconsImg(IMG_Load("test-data/targeting-icons.png"));
355                 Sprite weaponTargetCursor(targetingIconsImg, 32, 32);
356                 Sprite magicTargetCursor(targetingIconsImg, 32, 32, 0, 32);
357                 Sprite itemTargetCursor(targetingIconsImg, 32, 32, 0, 64);
358                 battleRes.weaponTargetCursor = &weaponTargetCursor;
359                 battleRes.magicTargetCursor = &magicTargetCursor;
360                 battleRes.itemTargetCursor = &itemTargetCursor;
361
362                 Spell resetSpell;
363                 resetSpell.SetName("Reset");
364                 maxim.AddSpell(&resetSpell);
365                 Spell strongSpell;
366                 strongSpell.SetName("Strong");
367                 strongSpell.SetCost(3);
368                 strongSpell.SetUsableInBattle();
369                 strongSpell.GetTargetingMode().TargetMultipleAllies();
370                 maxim.AddSpell(&strongSpell);
371                 selan.AddSpell(&strongSpell);
372                 Spell strongerSpell;
373                 strongerSpell.SetName("Stronger");
374                 strongerSpell.SetCost(8);
375                 strongerSpell.SetUsableInBattle();
376                 strongerSpell.GetTargetingMode().TargetMultipleAllies();
377                 maxim.AddSpell(&strongerSpell);
378                 selan.AddSpell(&strongerSpell);
379                 Spell championSpell;
380                 championSpell.SetName("Champion");
381                 championSpell.SetCost(16);
382                 championSpell.SetUsableInBattle();
383                 championSpell.GetTargetingMode().TargetMultipleAllies();
384                 maxim.AddSpell(&championSpell);
385                 selan.AddSpell(&championSpell);
386                 Spell rallySpell;
387                 rallySpell.SetName("Rally");
388                 rallySpell.SetCost(10);
389                 rallySpell.SetUsableInBattle();
390                 rallySpell.GetTargetingMode().TargetMultipleAllies();
391                 maxim.AddSpell(&rallySpell);
392                 selan.AddSpell(&rallySpell);
393                 Spell escapeSpell;
394                 escapeSpell.SetName("Escape");
395                 escapeSpell.SetCost(8);
396                 selan.AddSpell(&escapeSpell);
397                 Spell valorSpell;
398                 valorSpell.SetName("Valor");
399                 valorSpell.SetCost(30);
400                 valorSpell.SetUsableInBattle();
401                 valorSpell.GetTargetingMode().TargetMultipleAllies();
402                 maxim.AddSpell(&valorSpell);
403                 selan.AddSpell(&valorSpell);
404
405                 battleRes.spellMenuHeadline = "Please choose a spell.";
406                 battleRes.spellMenuPrototype = Menu<const Spell *>(&normalFont, &disabledFont, &handCursorSprite, 9, 6, 8, 0, 2, 32, 2, ':');
407
408                 SDL_Surface *itemIcons(IMG_Load("test-data/item-icons.png"));
409                 Sprite potionIcon(itemIcons, 16, 16);
410                 Sprite ballIcon(itemIcons, 16, 16, 0, 16);
411                 Sprite crankIcon(itemIcons, 16, 16, 0, 32);
412                 Sprite spearIcon(itemIcons, 16, 16, 0, 48);
413                 Sprite swordIcon(itemIcons, 16, 16, 0, 64);
414                 Sprite axIcon(itemIcons, 16, 16, 0, 80);
415                 Sprite rodIcon(itemIcons, 16, 16, 0, 96);
416                 Sprite armorIcon(itemIcons, 16, 16, 0, 112);
417                 Sprite shieldIcon(itemIcons, 16, 16, 0, 128);
418                 Sprite helmetIcon(itemIcons, 16, 16, 0, 144);
419                 Sprite ringIcon(itemIcons, 16, 16, 0, 160);
420                 Sprite jewelIcon(itemIcons, 16, 16, 0, 176);
421
422                 battleRes.weaponMenuIcon = &swordIcon;
423                 battleRes.armorMenuIcon = &armorIcon;
424                 battleRes.shieldMenuIcon = &shieldIcon;
425                 battleRes.helmetMenuIcon = &helmetIcon;
426                 battleRes.ringMenuIcon = &ringIcon;
427                 battleRes.jewelMenuIcon = &jewelIcon;
428
429                 Inventory inventory;
430                 Item antidote;
431                 antidote.SetName("Antidote");
432                 antidote.SetMenuIcon(&potionIcon);
433                 antidote.SetUsableInBattle();
434                 antidote.GetTargetingMode().TargetSingleAlly();
435                 inventory.Add(&antidote, 9);
436                 Item magicJar;
437                 magicJar.SetName("Magic jar");
438                 magicJar.SetMenuIcon(&potionIcon);
439                 magicJar.SetUsableInBattle();
440                 magicJar.GetTargetingMode().TargetSingleAlly();
441                 inventory.Add(&magicJar, 4);
442                 Item hiPotion;
443                 hiPotion.SetName("Hi-Potion");
444                 hiPotion.SetMenuIcon(&potionIcon);
445                 hiPotion.SetUsableInBattle();
446                 hiPotion.GetTargetingMode().TargetSingleAlly();
447                 inventory.Add(&hiPotion, 4);
448                 Item powerPotion;
449                 powerPotion.SetName("Power potion");
450                 powerPotion.SetMenuIcon(&potionIcon);
451                 inventory.Add(&powerPotion, 4);
452                 Item escape;
453                 escape.SetName("Escape");
454                 inventory.Add(&escape, 2);
455                 Item sleepBall;
456                 sleepBall.SetName("Sleep ball");
457                 sleepBall.SetMenuIcon(&ballIcon);
458                 sleepBall.SetUsableInBattle();
459                 sleepBall.GetTargetingMode().TargetSingleEnemy();
460                 inventory.Add(&sleepBall, 1);
461                 Item multiBall;
462                 multiBall.SetName("Multi-ball!");
463                 multiBall.SetMenuIcon(&ballIcon);
464                 multiBall.SetUsableInBattle();
465                 multiBall.GetTargetingMode().TargetMultipleEnemies();
466                 inventory.Add(&multiBall, 1);
467                 Item figgoru;
468                 figgoru.SetName("Figgoru");
469                 figgoru.SetMenuIcon(&crankIcon);
470                 figgoru.GetTargetingMode().TargetAllEnemies();
471                 inventory.Add(&figgoru, 1);
472                 battleRes.inventory = &inventory;
473
474                 battleRes.itemMenuHeadline = "Please choose an item.";
475                 battleRes.itemMenuPrototype = Menu<const common::Item *>(&normalFont, &disabledFont, &handCursorSprite, 15, 6, 8, 16, 1, 32, 2, ':');
476
477                 SDL_Surface *swordAttackImg(IMG_Load("test-data/attack-sword.png"));
478                 Sprite swordAttackSprite(swordAttackImg, 96, 96);
479                 SimpleAnimation swordAttackAnimation(&swordAttackSprite, 2 * framerate, 4);
480
481                 Item zircoSword;
482                 zircoSword.SetName("Zirco sword");
483                 zircoSword.SetMenuIcon(&swordIcon);
484                 Ikari firestorm;
485                 firestorm.SetName("Firestorm");
486                 firestorm.SetCost(224);
487                 firestorm.GetTargetingMode().TargetAllEnemies();
488                 firestorm.SetPhysical();
489                 zircoSword.SetIkari(&firestorm);
490                 zircoSword.SetAttackAnimation(&swordAttackAnimation);
491                 maxim.SetWeapon(&zircoSword);
492                 Item zirconArmor;
493                 zirconArmor.SetName("Zircon armor");
494                 zirconArmor.SetMenuIcon(&armorIcon);
495                 Ikari magicCure;
496                 magicCure.SetName("Magic cure");
497                 magicCure.SetCost(128);
498                 magicCure.GetTargetingMode().TargetSingleAlly();
499                 magicCure.SetMagical();
500                 zirconArmor.SetIkari(&magicCure);
501                 maxim.SetArmor(&zirconArmor);
502                 Item holyShield;
503                 holyShield.SetName("Holy shield");
504                 holyShield.SetMenuIcon(&shieldIcon);
505                 Ikari lightGuard;
506                 lightGuard.SetName("Light guard");
507                 lightGuard.SetCost(128);
508                 lightGuard.GetTargetingMode().TargetAllAllies(); // FIXME: actually only targets self
509                 lightGuard.SetMagical();
510                 holyShield.SetIkari(&lightGuard);
511                 maxim.SetShield(&holyShield);
512                 Item legendHelm;
513                 legendHelm.SetName("Legend helm");
514                 legendHelm.SetMenuIcon(&helmetIcon);
515                 Ikari boomerang;
516                 boomerang.SetName("Boomerang");
517                 boomerang.SetCost(164);
518                 boomerang.GetTargetingMode().TargetAllAllies(); // FIXME: actually only targets self
519                 boomerang.SetMagical();
520                 legendHelm.SetIkari(&boomerang);
521                 maxim.SetHelmet(&legendHelm);
522                 Item sProRing;
523                 sProRing.SetName("S-pro ring");
524                 sProRing.SetMenuIcon(&ringIcon);
525                 Ikari courage;
526                 courage.SetName("Courage");
527                 courage.SetCost(64);
528                 courage.GetTargetingMode().TargetMultipleAllies();
529                 courage.SetMagical();
530                 sProRing.SetIkari(&courage);
531                 maxim.SetRing(&sProRing);
532                 Item evilJewel;
533                 evilJewel.SetName("Evil jewel");
534                 evilJewel.SetMenuIcon(&jewelIcon);
535                 Ikari gloomy;
536                 gloomy.SetName("Gloomy");
537                 gloomy.SetCost(164);
538                 gloomy.GetTargetingMode().TargetAllEnemies();
539                 gloomy.SetMagical();
540                 evilJewel.SetIkari(&gloomy);
541                 maxim.SetJewel(&evilJewel);
542
543                 Item zircoWhip;
544                 zircoWhip.SetName("Zirco whip");
545                 zircoWhip.SetMenuIcon(&rodIcon);
546                 Ikari thundershriek;
547                 thundershriek.SetName("Thundershriek");
548                 thundershriek.SetCost(224);
549                 thundershriek.GetTargetingMode().TargetAllEnemies();
550                 thundershriek.SetPhysical();
551                 zircoWhip.SetIkari(&thundershriek);
552 //              selan.SetWeapon(&zircoWhip);
553                 Item zirconPlate;
554                 zirconPlate.SetName("Zircon plate");
555                 zirconPlate.SetMenuIcon(&armorIcon);
556                 Ikari suddenCure;
557                 suddenCure.SetName("Sudden cure");
558                 suddenCure.SetCost(96);
559                 suddenCure.GetTargetingMode().TargetAllAllies();
560                 suddenCure.SetMagical();
561                 zirconPlate.SetIkari(&suddenCure);
562                 selan.SetArmor(&zirconPlate);
563                 Item zircoGloves;
564                 zircoGloves.SetName("Zirco gloves");
565                 zircoGloves.SetMenuIcon(&shieldIcon);
566                 Ikari forcefield;
567                 forcefield.SetName("Forcefield");
568                 forcefield.SetCost(64);
569                 forcefield.GetTargetingMode().TargetAllAllies();
570                 forcefield.SetMagical();
571                 zircoGloves.SetIkari(&forcefield);
572                 selan.SetShield(&zircoGloves);
573                 Item holyCap;
574                 holyCap.SetName("Holy cap");
575                 holyCap.SetMenuIcon(&helmetIcon);
576                 Ikari vulnerable;
577                 vulnerable.SetName("Vulnerable");
578                 vulnerable.SetCost(196);
579                 vulnerable.GetTargetingMode().TargetAllEnemies();
580                 vulnerable.SetPhysical();
581                 holyCap.SetIkari(&vulnerable);
582                 selan.SetHelmet(&holyCap);
583                 Item ghostRing;
584                 ghostRing.SetName("Ghost ring");
585                 ghostRing.SetMenuIcon(&ringIcon);
586                 Ikari destroy;
587                 destroy.SetName("Destroy");
588                 destroy.SetCost(128);
589                 destroy.GetTargetingMode().TargetMultipleEnemies();
590                 destroy.SetMagical();
591                 ghostRing.SetIkari(&destroy);
592                 selan.SetRing(&ghostRing);
593                 Item eagleRock;
594                 eagleRock.SetName("Eagle rock");
595                 eagleRock.SetMenuIcon(&jewelIcon);
596                 Ikari dive;
597                 dive.SetName("Dive");
598                 dive.SetCost(128);
599                 dive.GetTargetingMode().TargetSingleEnemy();
600                 dive.SetPhysical();
601                 eagleRock.SetIkari(&dive);
602                 selan.SetJewel(&eagleRock);
603
604                 Item zircoAx;
605                 zircoAx.SetName("Zirco ax");
606                 zircoAx.SetMenuIcon(&axIcon);
607                 Ikari torrent;
608                 torrent.SetName("Torrent");
609                 torrent.SetCost(224);
610                 torrent.GetTargetingMode().TargetAllEnemies();
611                 torrent.SetPhysical();
612                 zircoAx.SetIkari(&torrent);
613 //              guy.SetWeapon(&zircoAx);
614                 guy.SetArmor(&zirconArmor);
615                 Item megaShield;
616                 megaShield.SetName("Mega shield");
617                 megaShield.SetMenuIcon(&shieldIcon);
618                 Ikari ironBarrier;
619                 ironBarrier.SetName("Iron barrier");
620                 ironBarrier.SetCost(255);
621                 ironBarrier.GetTargetingMode().TargetAllAllies(); // FIXME: actually only targets self
622                 ironBarrier.SetMagical();
623                 megaShield.SetIkari(&ironBarrier);
624                 guy.SetShield(&megaShield);
625                 Item zircoHelmet;
626                 zircoHelmet.SetName("Zirco helmet");
627                 zircoHelmet.SetMenuIcon(&helmetIcon);
628                 Ikari slow;
629                 slow.SetName("Slow");
630                 slow.SetCost(196);
631                 slow.GetTargetingMode().TargetAllEnemies();
632                 slow.SetPhysical();
633                 zircoHelmet.SetIkari(&slow);
634                 guy.SetHelmet(&zircoHelmet);
635                 Item powerRing;
636                 powerRing.SetName("Power ring");
637                 powerRing.SetMenuIcon(&ringIcon);
638                 Ikari trick;
639                 trick.SetName("Trick");
640                 trick.SetCost(32);
641                 trick.GetTargetingMode().TargetAllEnemies();
642                 trick.SetMagical();
643                 zircoHelmet.SetIkari(&trick);
644                 guy.SetRing(&powerRing);
645                 guy.SetJewel(&evilJewel);
646
647                 // NOTE: this is actually Artea equipment
648                 Item lizardBlow;
649                 lizardBlow.SetName("Lizard blow");
650                 lizardBlow.SetMenuIcon(&swordIcon);
651                 Ikari dragonRush;
652                 dragonRush.SetName("Dragon rush");
653                 dragonRush.SetCost(164);
654                 dragonRush.GetTargetingMode().TargetSingleEnemy();
655                 dragonRush.SetPhysical();
656                 lizardBlow.SetIkari(&dragonRush);
657 //              dekar.SetWeapon(&lizardBlow);
658                 Item holyRobe;
659                 holyRobe.SetName("Holy robe");
660                 holyRobe.SetMenuIcon(&armorIcon);
661                 Ikari crisisCure;
662                 crisisCure.SetName("Crisis cure");
663                 crisisCure.SetCost(164);
664                 crisisCure.GetTargetingMode().TargetAllAllies();
665                 crisisCure.SetMagical();
666                 holyRobe.SetIkari(&crisisCure);
667                 dekar.SetArmor(&holyRobe);
668                 dekar.SetShield(&zircoGloves);
669                 dekar.SetHelmet(&holyCap);
670                 Item rocketRing;
671                 rocketRing.SetName("Rocket ring");
672                 rocketRing.SetMenuIcon(&ringIcon);
673                 Ikari fake;
674                 fake.SetName("Fake");
675                 fake.SetCost(32);
676                 fake.GetTargetingMode().TargetSingleAlly();
677                 fake.SetMagical();
678                 rocketRing.SetIkari(&fake);
679                 dekar.SetRing(&rocketRing);
680                 Item krakenRock;
681                 krakenRock.SetName("Kraken rock");
682                 krakenRock.SetMenuIcon(&jewelIcon);
683                 Ikari tenLegger;
684                 tenLegger.SetName("Ten-legger");
685                 tenLegger.SetCost(164);
686                 tenLegger.GetTargetingMode().TargetAllEnemies();
687                 tenLegger.SetPhysical();
688                 rocketRing.SetIkari(&tenLegger);
689                 dekar.SetJewel(&krakenRock);
690
691                 battleRes.ikariMenuHeadline = "Please choose equipment.";
692                 battleRes.noEquipmentText = "No equip";
693                 battleRes.ikariMenuPrototype = Menu<const Item *>(&normalFont, &disabledFont, &handCursorSprite, 12, 6, normalFont.CharHeight() / 2, normalFont.CharWidth(), 1, normalFont.CharWidth() * 2, 0, ':', 12, normalFont.CharWidth());
694
695                 battleRes.escapeText = "Escapes.";
696
697                 BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &battleRes));
698                 battleState->AddMonster(monster);
699                 battleState->AddMonster(monster);
700                 battleState->AddMonster(monster);
701                 battleState->AddMonster(monster);
702                 battleState->AddHero(maxim);
703                 battleState->AddHero(selan);
704                 battleState->AddHero(guy);
705                 battleState->AddHero(dekar);
706                 Application app(&screen, battleState);
707                 app.Buttons().MapKey(SDLK_w, Input::PAD_UP);
708                 app.Buttons().MapKey(SDLK_d, Input::PAD_RIGHT);
709                 app.Buttons().MapKey(SDLK_s, Input::PAD_DOWN);
710                 app.Buttons().MapKey(SDLK_a, Input::PAD_LEFT);
711                 app.Buttons().MapKey(SDLK_RIGHT, Input::ACTION_A);
712                 app.Buttons().MapKey(SDLK_DOWN, Input::ACTION_B);
713                 app.Buttons().MapKey(SDLK_UP, Input::ACTION_X);
714                 app.Buttons().MapKey(SDLK_LEFT, Input::ACTION_Y);
715                 app.Buttons().MapKey(SDLK_RETURN, Input::START);
716                 app.Buttons().MapKey(SDLK_SPACE, Input::SELECT);
717                 app.Buttons().MapKey(SDLK_RSHIFT, Input::SHOULDER_RIGHT);
718                 app.Buttons().MapKey(SDLK_LSHIFT, Input::SHOULDER_LEFT);
719                 app.Run();
720
721                 return 0;
722         } catch (exception &e) {
723                 cerr << "exception in main(): " << e.what() << endl;
724                 return 1;
725         }
726 }