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