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/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"
38 #include <SDL_image.h>
40 using app::Application;
42 using battle::BattleState;
44 using battle::Monster;
45 using battle::PartyLayout;
48 using common::Inventory;
51 using geometry::Point;
52 using geometry::Vector;
53 using graphics::ComplexAnimation;
55 using graphics::Frame;
56 using graphics::Gauge;
58 using graphics::SimpleAnimation;
59 using graphics::Sprite;
61 using sdl::InitScreen;
69 int main(int argc, char **argv) {
70 const int width = 800;
71 const int height = 480;
73 const int framerate = 33;
75 // std::srand(std::time(0));
79 InitImage image(IMG_INIT_PNG);
80 InitScreen screen(width, height);
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));
95 SDL_Surface *monsterImg(IMG_Load("test-data/monster.png"));
96 Sprite monsterSprite(monsterImg, 64, 64);
98 monster.SetName("Lizard");
99 monster.SetSprite(&monsterSprite);
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);
115 SDL_Surface *maximImg(IMG_Load("test-data/maxim.png"));
116 Sprite maximSprite(maximImg, 64, 64);
118 maxim.SetName("Maxim");
120 maxim.SetSprite(&maximSprite);
121 maxim.SetMaxHealth(33);
123 maxim.SetMaxMana(20);
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);
149 SDL_Surface *selanImg(IMG_Load("test-data/selan.png"));
150 Sprite selanSprite(selanImg, 64, 64);
152 selan.SetName("Selan");
154 selan.SetSprite(&selanSprite);
155 selan.SetMaxHealth(28);
157 selan.SetMaxMana(23);
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);
184 SDL_Surface *guyImg(IMG_Load("test-data/guy.png"));
185 Sprite guySprite(guyImg, 64, 64);
189 guy.SetSprite(&guySprite);
190 guy.SetMaxHealth(38);
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);
213 SDL_Surface *dekarImg(IMG_Load("test-data/dekar.png"));
214 Sprite dekarSprite(dekarImg, 64, 64);
216 dekar.SetName("Dekar");
218 dekar.SetSprite(&dekarSprite);
219 dekar.SetMaxHealth(38);
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);
246 battle::Resources battleRes;
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;
261 SDL_Surface *titleFrameImg(IMG_Load("test-data/title-frame.png"));
262 Frame titleFrame(titleFrameImg, 16, 16);
263 battleRes.titleFrame = &titleFrame;
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;
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;
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;
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;
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);
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;
340 SDL_Surface *selectFrameImg(IMG_Load("test-data/select-frame.png"));
341 Frame selectFrame(selectFrameImg, 16, 16);
342 battleRes.selectFrame = &selectFrame;
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;
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;
354 SDL_Surface *handCursorImg(IMG_Load("test-data/cursor-hand.png"));
355 Sprite handCursorSprite(handCursorImg, 32, 32);
356 battleRes.menuCursor = &handCursorSprite;
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;
367 resetSpell.SetName("Reset");
368 maxim.AddSpell(&resetSpell);
370 strongSpell.SetName("Strong");
371 strongSpell.SetCost(3);
372 strongSpell.SetUsableInBattle();
373 strongSpell.GetTargetingMode().TargetMultipleAllies();
374 maxim.AddSpell(&strongSpell);
375 selan.AddSpell(&strongSpell);
377 strongerSpell.SetName("Stronger");
378 strongerSpell.SetCost(8);
379 strongerSpell.SetUsableInBattle();
380 strongerSpell.GetTargetingMode().TargetMultipleAllies();
381 maxim.AddSpell(&strongerSpell);
382 selan.AddSpell(&strongerSpell);
384 championSpell.SetName("Champion");
385 championSpell.SetCost(16);
386 championSpell.SetUsableInBattle();
387 championSpell.GetTargetingMode().TargetMultipleAllies();
388 maxim.AddSpell(&championSpell);
389 selan.AddSpell(&championSpell);
391 rallySpell.SetName("Rally");
392 rallySpell.SetCost(10);
393 rallySpell.SetUsableInBattle();
394 rallySpell.GetTargetingMode().TargetMultipleAllies();
395 maxim.AddSpell(&rallySpell);
396 selan.AddSpell(&rallySpell);
398 escapeSpell.SetName("Escape");
399 escapeSpell.SetCost(8);
400 selan.AddSpell(&escapeSpell);
402 valorSpell.SetName("Valor");
403 valorSpell.SetCost(30);
404 valorSpell.SetUsableInBattle();
405 valorSpell.GetTargetingMode().TargetMultipleAllies();
406 maxim.AddSpell(&valorSpell);
407 selan.AddSpell(&valorSpell);
409 battleRes.spellMenuHeadline = "Please choose a spell.";
410 battleRes.spellMenuPrototype = Menu<const Spell *>(&normalFont, &disabledFont, &handCursorSprite, 9, 6, 8, 0, 2, 32, 2, ':');
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);
426 battleRes.weaponMenuIcon = &swordIcon;
427 battleRes.armorMenuIcon = &armorIcon;
428 battleRes.shieldMenuIcon = &shieldIcon;
429 battleRes.helmetMenuIcon = &helmetIcon;
430 battleRes.ringMenuIcon = &ringIcon;
431 battleRes.jewelMenuIcon = &jewelIcon;
435 antidote.SetName("Antidote");
436 antidote.SetMenuIcon(&potionIcon);
437 antidote.SetUsableInBattle();
438 antidote.GetTargetingMode().TargetSingleAlly();
439 inventory.Add(&antidote, 9);
441 magicJar.SetName("Magic jar");
442 magicJar.SetMenuIcon(&potionIcon);
443 magicJar.SetUsableInBattle();
444 magicJar.GetTargetingMode().TargetSingleAlly();
445 inventory.Add(&magicJar, 4);
447 hiPotion.SetName("Hi-Potion");
448 hiPotion.SetMenuIcon(&potionIcon);
449 hiPotion.SetUsableInBattle();
450 hiPotion.GetTargetingMode().TargetSingleAlly();
451 inventory.Add(&hiPotion, 4);
453 powerPotion.SetName("Power potion");
454 powerPotion.SetMenuIcon(&potionIcon);
455 inventory.Add(&powerPotion, 4);
457 escape.SetName("Escape");
458 inventory.Add(&escape, 2);
460 sleepBall.SetName("Sleep ball");
461 sleepBall.SetMenuIcon(&ballIcon);
462 sleepBall.SetUsableInBattle();
463 sleepBall.GetTargetingMode().TargetSingleEnemy();
464 inventory.Add(&sleepBall, 1);
466 multiBall.SetName("Multi-ball!");
467 multiBall.SetMenuIcon(&ballIcon);
468 multiBall.SetUsableInBattle();
469 multiBall.GetTargetingMode().TargetMultipleEnemies();
470 inventory.Add(&multiBall, 1);
472 figgoru.SetName("Figgoru");
473 figgoru.SetMenuIcon(&crankIcon);
474 figgoru.GetTargetingMode().TargetAllEnemies();
475 inventory.Add(&figgoru, 1);
476 battleRes.inventory = &inventory;
478 battleRes.itemMenuHeadline = "Please choose an item.";
479 battleRes.itemMenuPrototype = Menu<const common::Item *>(&normalFont, &disabledFont, &handCursorSprite, 15, 6, 8, 16, 1, 32, 2, ':');
481 SDL_Surface *swordAttackImg(IMG_Load("test-data/attack-sword.png"));
482 Sprite swordAttackSprite(swordAttackImg, 96, 96);
483 SimpleAnimation swordAttackAnimation(&swordAttackSprite, 2 * framerate, 4);
486 zircoSword.SetName("Zirco sword");
487 zircoSword.SetMenuIcon(&swordIcon);
489 firestorm.SetName("Firestorm");
490 firestorm.SetCost(224);
491 firestorm.GetTargetingMode().TargetAllEnemies();
492 firestorm.SetPhysical();
493 zircoSword.SetIkari(&firestorm);
494 zircoSword.SetAttackAnimation(&swordAttackAnimation);
495 maxim.SetWeapon(&zircoSword);
497 zirconArmor.SetName("Zircon armor");
498 zirconArmor.SetMenuIcon(&armorIcon);
500 magicCure.SetName("Magic cure");
501 magicCure.SetCost(128);
502 magicCure.GetTargetingMode().TargetSingleAlly();
503 magicCure.SetMagical();
504 zirconArmor.SetIkari(&magicCure);
505 maxim.SetArmor(&zirconArmor);
507 holyShield.SetName("Holy shield");
508 holyShield.SetMenuIcon(&shieldIcon);
510 lightGuard.SetName("Light guard");
511 lightGuard.SetCost(128);
512 lightGuard.GetTargetingMode().TargetAllAllies(); // FIXME: actually only targets self
513 lightGuard.SetMagical();
514 holyShield.SetIkari(&lightGuard);
515 maxim.SetShield(&holyShield);
517 legendHelm.SetName("Legend helm");
518 legendHelm.SetMenuIcon(&helmetIcon);
520 boomerang.SetName("Boomerang");
521 boomerang.SetCost(164);
522 boomerang.GetTargetingMode().TargetAllAllies(); // FIXME: actually only targets self
523 boomerang.SetMagical();
524 legendHelm.SetIkari(&boomerang);
525 maxim.SetHelmet(&legendHelm);
527 sProRing.SetName("S-pro ring");
528 sProRing.SetMenuIcon(&ringIcon);
530 courage.SetName("Courage");
532 courage.GetTargetingMode().TargetMultipleAllies();
533 courage.SetMagical();
534 sProRing.SetIkari(&courage);
535 maxim.SetRing(&sProRing);
537 evilJewel.SetName("Evil jewel");
538 evilJewel.SetMenuIcon(&jewelIcon);
540 gloomy.SetName("Gloomy");
542 gloomy.GetTargetingMode().TargetAllEnemies();
544 evilJewel.SetIkari(&gloomy);
545 maxim.SetJewel(&evilJewel);
548 zircoWhip.SetName("Zirco whip");
549 zircoWhip.SetMenuIcon(&rodIcon);
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);
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);
620 megaShield.SetName("Mega shield");
621 megaShield.SetMenuIcon(&shieldIcon);
623 ironBarrier.SetName("Iron barrier");
624 ironBarrier.SetCost(255);
625 ironBarrier.GetTargetingMode().TargetAllAllies(); // FIXME: actually only targets self
626 ironBarrier.SetMagical();
627 megaShield.SetIkari(&ironBarrier);
628 guy.SetShield(&megaShield);
630 zircoHelmet.SetName("Zirco helmet");
631 zircoHelmet.SetMenuIcon(&helmetIcon);
633 slow.SetName("Slow");
635 slow.GetTargetingMode().TargetAllEnemies();
637 zircoHelmet.SetIkari(&slow);
638 guy.SetHelmet(&zircoHelmet);
640 powerRing.SetName("Power ring");
641 powerRing.SetMenuIcon(&ringIcon);
643 trick.SetName("Trick");
645 trick.GetTargetingMode().TargetAllEnemies();
647 zircoHelmet.SetIkari(&trick);
648 guy.SetRing(&powerRing);
649 guy.SetJewel(&evilJewel);
651 // NOTE: this is actually Artea equipment
653 lizardBlow.SetName("Lizard blow");
654 lizardBlow.SetMenuIcon(&swordIcon);
656 dragonRush.SetName("Dragon rush");
657 dragonRush.SetCost(164);
658 dragonRush.GetTargetingMode().TargetSingleEnemy();
659 dragonRush.SetPhysical();
660 lizardBlow.SetIkari(&dragonRush);
661 // dekar.SetWeapon(&lizardBlow);
663 holyRobe.SetName("Holy robe");
664 holyRobe.SetMenuIcon(&armorIcon);
666 crisisCure.SetName("Crisis cure");
667 crisisCure.SetCost(164);
668 crisisCure.GetTargetingMode().TargetAllAllies();
669 crisisCure.SetMagical();
670 holyRobe.SetIkari(&crisisCure);
671 dekar.SetArmor(&holyRobe);
672 dekar.SetShield(&zircoGloves);
673 dekar.SetHelmet(&holyCap);
675 rocketRing.SetName("Rocket ring");
676 rocketRing.SetMenuIcon(&ringIcon);
678 fake.SetName("Fake");
680 fake.GetTargetingMode().TargetSingleAlly();
682 rocketRing.SetIkari(&fake);
683 dekar.SetRing(&rocketRing);
685 krakenRock.SetName("Kraken rock");
686 krakenRock.SetMenuIcon(&jewelIcon);
688 tenLegger.SetName("Ten-legger");
689 tenLegger.SetCost(164);
690 tenLegger.GetTargetingMode().TargetAllEnemies();
691 tenLegger.SetPhysical();
692 rocketRing.SetIkari(&tenLegger);
693 dekar.SetJewel(&krakenRock);
695 battleRes.ikariMenuHeadline = "Please choose equipment.";
696 battleRes.noEquipmentText = "No equip";
697 battleRes.ikariMenuPrototype = Menu<const Item *>(&normalFont, &disabledFont, &handCursorSprite, 12, 6, normalFont.CharHeight() / 2, normalFont.CharWidth(), 1, normalFont.CharWidth() * 2, 0, ':', 12, normalFont.CharWidth());
699 battleRes.escapeText = "Escapes.";
701 BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &battleRes));
702 battleState->AddMonster(monster);
703 battleState->AddMonster(monster);
704 battleState->AddMonster(monster);
705 battleState->AddMonster(monster);
706 battleState->AddHero(maxim);
707 battleState->AddHero(selan);
708 battleState->AddHero(guy);
709 battleState->AddHero(dekar);
710 Application app(&screen, battleState);
711 app.Buttons().MapKey(SDLK_w, Input::PAD_UP);
712 app.Buttons().MapKey(SDLK_d, Input::PAD_RIGHT);
713 app.Buttons().MapKey(SDLK_s, Input::PAD_DOWN);
714 app.Buttons().MapKey(SDLK_a, Input::PAD_LEFT);
715 app.Buttons().MapKey(SDLK_RIGHT, Input::ACTION_A);
716 app.Buttons().MapKey(SDLK_DOWN, Input::ACTION_B);
717 app.Buttons().MapKey(SDLK_UP, Input::ACTION_X);
718 app.Buttons().MapKey(SDLK_LEFT, Input::ACTION_Y);
719 app.Buttons().MapKey(SDLK_RETURN, Input::START);
720 app.Buttons().MapKey(SDLK_SPACE, Input::SELECT);
721 app.Buttons().MapKey(SDLK_RSHIFT, Input::SHOULDER_RIGHT);
722 app.Buttons().MapKey(SDLK_LSHIFT, Input::SHOULDER_LEFT);
726 } catch (exception &e) {
727 cerr << "exception in main(): " << e.what() << endl;