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