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