#include "battle/Monster.h"
#include "battle/PartyLayout.h"
#include "battle/Resources.h"
+#include "battle/Stats.h"
#include "common/Ikari.h"
#include "common/Inventory.h"
#include "common/Item.h"
#include "common/Spell.h"
-#include "geometry/Point.h"
#include "geometry/Vector.h"
#include "graphics/ComplexAnimation.h"
#include "graphics/Font.h"
#include "sdl/InitScreen.h"
#include "sdl/InitSDL.h"
+#include <cstdlib>
+#include <ctime>
#include <exception>
#include <iostream>
#include <SDL.h>
using battle::Hero;
using battle::Monster;
using battle::PartyLayout;
+using battle::Stats;
using common::Ikari;
using common::Inventory;
using common::Item;
using common::Spell;
-using geometry::Point;
using geometry::Vector;
using graphics::ComplexAnimation;
using graphics::Font;
const int framerate = 33;
+// std::srand(std::time(0));
+
try {
InitSDL sdl;
InitImage image(IMG_INIT_PNG);
// temporary test data
SDL_Surface *bg(IMG_Load("test-data/battle-bg.png"));
PartyLayout monstersLayout;
- monstersLayout.AddPosition(Point<Uint8>(88, 88));
- monstersLayout.AddPosition(Point<Uint8>(128, 88));
- monstersLayout.AddPosition(Point<Uint8>(168, 88));
- monstersLayout.AddPosition(Point<Uint8>(208, 88));
+ monstersLayout.AddPosition(Vector<Uint8>(88, 88));
+ monstersLayout.AddPosition(Vector<Uint8>(128, 88));
+ monstersLayout.AddPosition(Vector<Uint8>(168, 88));
+ monstersLayout.AddPosition(Vector<Uint8>(208, 88));
PartyLayout heroesLayout;
- heroesLayout.AddPosition(Point<Uint8>(48, 136));
- heroesLayout.AddPosition(Point<Uint8>(128, 136));
- heroesLayout.AddPosition(Point<Uint8>(80, 152));
- heroesLayout.AddPosition(Point<Uint8>(160, 152));
+ heroesLayout.AddPosition(Vector<Uint8>(48, 136));
+ heroesLayout.AddPosition(Vector<Uint8>(128, 136));
+ heroesLayout.AddPosition(Vector<Uint8>(80, 152));
+ heroesLayout.AddPosition(Vector<Uint8>(160, 152));
SDL_Surface *monsterImg(IMG_Load("test-data/monster.png"));
- Sprite dummySprite(monsterImg, 64, 64);
+ Sprite monsterSprite(monsterImg, 64, 64);
Monster monster;
- monster.SetName("Monster");
- monster.SetSprite(&dummySprite);
- monster.SetMaxHealth(10);
- monster.SetHealth(10);
+ monster.SetName("Lizard");
+ monster.SetSprite(&monsterSprite);
+ monster.SetLevel(1);
+ monster.SetMaxHealth(8);
+ monster.SetHealth(8);
+ monster.SetStats(Stats(14, 6, 6, 6, 6, 6, 6));
+ monster.SetReward(3, 5);
+ ComplexAnimation monsterAttackAnimation(&monsterSprite, 4 * framerate);
+ monsterAttackAnimation.AddFrame(0, 1, Vector<int>(0, 16));
+ monsterAttackAnimation.AddFrame(0, 0, Vector<int>(0, 16));
+ monsterAttackAnimation.AddFrame(0, 1, Vector<int>(0, 16));
+ monster.SetAttackAnimation(&monsterAttackAnimation);
+ SDL_Surface *monsterMeleeImg(IMG_Load("test-data/attack-monster.png"));
+ Sprite monsterMeleeSprite(monsterMeleeImg, 96, 64);
+ SimpleAnimation monsterMeleeAnimation(&monsterMeleeSprite, framerate, 14);
+ monster.SetMeleeAnimation(&monsterMeleeAnimation);
SDL_Surface *maximImg(IMG_Load("test-data/maxim.png"));
Sprite maximSprite(maximImg, 64, 64);
maxim.SetMaxMana(20);
maxim.SetMana(20);
maxim.SetIP(0);
+ maxim.SetStats(Stats(28, 22, 28, 17, 14, 100, 10));
ComplexAnimation maximAttackAnimation(&maximSprite, framerate);
// TODO: cross check double frames; could be related to differences in framerates
maximAttackAnimation.AddFrames(1, 0, Vector<int>(0, 0), 7); // TODO: maybe this could also be a pause before the battle animation
selan.SetHealth(28);
selan.SetMaxMana(23);
selan.SetMana(23);
- selan.SetIP(1);
+ selan.SetIP(0);
+ selan.SetStats(Stats(23, 21, 23, 19, 22, 80, 13));
ComplexAnimation selanAttackAnimation(&selanSprite, framerate);
selanAttackAnimation.AddFrames(1, 0, Vector<int>(4, 0), 2);
selanAttackAnimation.AddFrame(1, 0, Vector<int>(8, 2));
guy.SetHealth(38);
guy.SetMaxMana(0);
guy.SetMana(0);
- guy.SetIP(254);
+ guy.SetIP(0);
+ guy.SetStats(Stats(38, 25, 38, 13, 8, 90, 8));
ComplexAnimation guyAttackAnimation(&guySprite, framerate);
guyAttackAnimation.AddFrames(1, 0, Vector<int>(-4, 0), 2);
guyAttackAnimation.AddFrames(1, 0, Vector<int>(-8, 0), 2);
dekar.SetHealth(38);
dekar.SetMaxMana(0);
dekar.SetMana(0);
- dekar.SetIP(255);
+ dekar.SetIP(0);
+ dekar.SetStats(Stats(46, 29, 46, 13, 7, 100, 5));
ComplexAnimation dekarAttackAnimation(&dekarSprite, framerate);
dekarAttackAnimation.AddFrame(1, 0, Vector<int>(4, 0));
dekarAttackAnimation.AddFrame(1, 0, Vector<int>(8, 2));
Font largeFont(&largeFontSprite, 0, -2);
battleRes.titleFont = &largeFont;
- battleRes.numberAnimationPrototype = ComplexAnimation(0, framerate);
- battleRes.numberAnimationPrototype.AddFrame(0, 0);
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -26));
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -42));
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -48));
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -42));
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -26));
- battleRes.numberAnimationPrototype.AddFrame(0, 0);
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -20));
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -24));
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -20));
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
- battleRes.numberAnimationPrototype.AddFrame(0, 0);
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -6));
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -10));
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -10));
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -6));
- battleRes.numberAnimationPrototype.AddFrames(0, 0, Vector<int>(), 14);
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -36));
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -32));
- battleRes.numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -18));
+ ComplexAnimation numberAnimationPrototype(0, framerate);
+ numberAnimationPrototype.AddFrame(0, 0);
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -26));
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -42));
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -48));
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -42));
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -26));
+ numberAnimationPrototype.AddFrame(0, 0);
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -20));
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -24));
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -20));
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
+ numberAnimationPrototype.AddFrame(0, 0);
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -6));
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -10));
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -10));
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -6));
+ numberAnimationPrototype.AddFrames(0, 0, Vector<int>(), 14);
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -36));
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -32));
+ numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -18));
+ battleRes.numberAnimationPrototype = &numberAnimationPrototype;
SDL_Surface *bigNumbersImg(IMG_Load("test-data/big-numbers.png"));
Sprite bigNumbersSprite(bigNumbersImg, 16, 32);
Sprite magicTargetCursor(targetingIconsImg, 32, 32, 0, 32);
Sprite itemTargetCursor(targetingIconsImg, 32, 32, 0, 64);
battleRes.weaponTargetCursor = &weaponTargetCursor;
- // TODO: add image for magic targeting cursor
battleRes.magicTargetCursor = &magicTargetCursor;
- // TODO: add image for item targeting cursor
battleRes.itemTargetCursor = &itemTargetCursor;
Spell resetSpell;
Item zircoSword;
zircoSword.SetName("Zirco sword");
zircoSword.SetMenuIcon(&swordIcon);
+ zircoSword.GetTargetingMode().TargetSingleEnemy();
Ikari firestorm;
firestorm.SetName("Firestorm");
firestorm.SetCost(224);
Item zircoWhip;
zircoWhip.SetName("Zirco whip");
zircoWhip.SetMenuIcon(&rodIcon);
+ zircoWhip.GetTargetingMode().TargetSingleEnemy();
Ikari thundershriek;
thundershriek.SetName("Thundershriek");
thundershriek.SetCost(224);
Item zircoAx;
zircoAx.SetName("Zirco ax");
zircoAx.SetMenuIcon(&axIcon);
+ zircoAx.GetTargetingMode().TargetSingleEnemy();
Ikari torrent;
torrent.SetName("Torrent");
torrent.SetCost(224);
Item lizardBlow;
lizardBlow.SetName("Lizard blow");
lizardBlow.SetMenuIcon(&swordIcon);
+ lizardBlow.GetTargetingMode().TargetSingleEnemy();
Ikari dragonRush;
dragonRush.SetName("Dragon rush");
dragonRush.SetCost(164);