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