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