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