#include "AttackTypeMenu.h"
-#include "../geometry/operators.h"
#include "../geometry/Vector.h"
#include "../graphics/Sprite.h"
-using geometry::Point;
using geometry::Vector;
namespace battle {
-void AttackTypeMenu::Render(SDL_Surface *screen, const geometry::Point<int> &position) {
+void AttackTypeMenu::Render(SDL_Surface *screen, const geometry::Vector<int> &position) {
Vector<int> swordOffset(IconWidth(), IconHeight());
Vector<int> magicOffset(IconWidth(), 0);
Vector<int> defendOffset(2 * IconWidth(), IconHeight());
#define BATTLE_ATTACKTYPEMENU_H_
#include "AttackChoice.h"
-#include "../geometry/Point.h"
+#include "../geometry/Vector.h"
#include "../graphics/Sprite.h"
#include <SDL.h>
public:
void Select(AttackChoice::Type t) { selected = t; }
AttackChoice::Type Selected() const { return selected; }
- void Render(SDL_Surface *screen, const geometry::Point<int> &position);
+ void Render(SDL_Surface *screen, const geometry::Vector<int> &position);
int Width() const { return 3 * IconWidth(); }
int Height() const { return 3 * IconHeight(); }
#include "../common/Inventory.h"
#include "../common/Item.h"
#include "../common/Spell.h"
-#include "../geometry/operators.h"
#include "../graphics/Frame.h"
#include "../graphics/Sprite.h"
using common::Inventory;
using common::Item;
using common::Spell;
-using geometry::Point;
using geometry::Vector;
using graphics::Menu;
int tagHeight(attackTypeMenu.Height());
int tagWidth(attackTypeMenu.Width() * 2 + attackTypeMenu.Width() / 2);
int xOffset((Width() - 2 * tagWidth) / 2);
- heroTagPositions[0] = Point<int>(xOffset, Height() - 2 * tagHeight);
- heroTagPositions[1] = Point<int>(xOffset + tagWidth, Height() - 2 * tagHeight);
- heroTagPositions[2] = Point<int>(xOffset, Height() - tagHeight);
- heroTagPositions[3] = Point<int>(xOffset + tagWidth, Height() - tagHeight);
+ heroTagPositions[0] = Vector<int>(xOffset, Height() - 2 * tagHeight);
+ heroTagPositions[1] = Vector<int>(xOffset + tagWidth, Height() - 2 * tagHeight);
+ heroTagPositions[2] = Vector<int>(xOffset, Height() - tagHeight);
+ heroTagPositions[3] = Vector<int>(xOffset + tagWidth, Height() - tagHeight);
tagHeight = res->normalFont->CharHeight() * 4 + res->smallHeroTagFrame->BorderHeight() * 2;
tagWidth = res->normalFont->CharWidth() * 6 + res->smallHeroTagFrame->BorderWidth() * 2;
xOffset = (Width() - 4 * tagWidth) / 2;
int yOffset(Height() - tagHeight);
- smallHeroTagPositions[0] = Point<int>(xOffset, yOffset);
- smallHeroTagPositions[1] = Point<int>(xOffset + 2 * tagWidth, yOffset);
- smallHeroTagPositions[2] = Point<int>(xOffset + tagWidth, yOffset);
- smallHeroTagPositions[3] = Point<int>(xOffset + 3 * tagWidth, yOffset);
+ smallHeroTagPositions[0] = Vector<int>(xOffset, yOffset);
+ smallHeroTagPositions[1] = Vector<int>(xOffset + 2 * tagWidth, yOffset);
+ smallHeroTagPositions[2] = Vector<int>(xOffset + tagWidth, yOffset);
+ smallHeroTagPositions[3] = Vector<int>(xOffset + 3 * tagWidth, yOffset);
itemMenu = res->itemMenuPrototype;
LoadInventory();
#include "Resources.h"
#include "SmallHeroTag.h"
#include "../app/State.h"
-#include "../geometry/Point.h"
#include "../geometry/Vector.h"
#include "../graphics/Animation.h"
#include "../graphics/Menu.h"
const Monster &MonsterAt(int index) const { assert(index >= 0 && index < NumHeroes()); return monsters[index]; }
const HeroTag &HeroTagAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTags[index]; }
- const geometry::Point<int> &HeroTagPositionAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTagPositions[index]; }
+ const geometry::Vector<int> &HeroTagPositionAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTagPositions[index]; }
bool HasChosenAttackType() const { return ActiveHero().GetAttackChoice().GetType() != AttackChoice::UNDECIDED; }
bool AttackSelectionDone() const { return activeHero >= numHeroes; }
graphics::Menu<const common::Item *> itemMenu;
HeroTag heroTags[4];
SmallHeroTag smallHeroTags[4];
- geometry::Point<int> heroTagPositions[4];
- geometry::Point<int> smallHeroTagPositions[4];
+ geometry::Vector<int> heroTagPositions[4];
+ geometry::Vector<int> smallHeroTagPositions[4];
int numHeroes;
int activeHero;
int attackCursor;
#include "AttackChoice.h"
#include "Stats.h"
-#include "../geometry/Point.h"
+#include "../geometry/Vector.h"
#include "../graphics/Animation.h"
#include "../graphics/Menu.h"
const graphics::Animation *AttackAnimation() const { return attackAnimation; }
const graphics::Animation *SpellAnimation() const { return spellAnimation; }
- geometry::Point<int> &Position() { return position; }
- const geometry::Point<int> &Position() const { return position; }
+ geometry::Vector<int> &Position() { return position; }
+ const geometry::Vector<int> &Position() const { return position; }
graphics::Menu<const common::Spell *> &SpellMenu() { return spellMenu; }
const graphics::Menu<const common::Spell *> &SpellMenu() const { return spellMenu; }
graphics::AnimationRunner animation;
- geometry::Point<int> position;
+ geometry::Vector<int> position;
graphics::Menu<const common::Spell *> spellMenu;
graphics::Menu<const common::Item *> ikariMenu;
#include "BattleState.h"
#include "Hero.h"
#include "Resources.h"
-#include "../geometry/operators.h"
#include "../geometry/Vector.h"
#include "../graphics/Font.h"
#include "../graphics/Frame.h"
#include "../graphics/Gauge.h"
#include "../graphics/Sprite.h"
-using geometry::Point;
using geometry::Vector;
using graphics::Frame;
return battle->HeroAt(index).Sprite();
}
-void HeroTag::Render(SDL_Surface *screen, int width, int height, Point<int> position, bool active) const {
+void HeroTag::Render(SDL_Surface *screen, int width, int height, Vector<int> position, bool active) const {
const Resources &r(battle->Res());
// frame
#define BATTLE_HEROTAG_H_
#include "Hero.h"
-#include "../geometry/Point.h"
#include "../geometry/Vector.h"
#include <SDL.h>
const graphics::Sprite *HeroSprite() const;
geometry::Vector<int> HeroOffset() const;
- void Render(SDL_Surface *screen, int width, int height, geometry::Point<int> position, bool active) const;
+ void Render(SDL_Surface *screen, int width, int height, geometry::Vector<int> position, bool active) const;
private:
const BattleState *battle;
#include "AttackChoice.h"
#include "Stats.h"
-#include "../geometry/Point.h"
+#include "../geometry/Vector.h"
#include "../graphics/Animation.h"
#include <SDL.h>
const graphics::Animation *AttackAnimation() const { return attackAnimation; }
const graphics::Animation *SpellAnimation() const { return spellAnimation; }
- geometry::Point<int> &Position() { return position; }
- const geometry::Point<int> &Position() const { return position; }
+ geometry::Vector<int> &Position() { return position; }
+ const geometry::Vector<int> &Position() const { return position; }
// temporary setters until loader is implemented
public:
graphics::AnimationRunner animation;
- geometry::Point<int> position;
+ geometry::Vector<int> position;
AttackChoice attackChoice;
#include "MoveMenu.h"
-#include "../geometry/operators.h"
#include "../geometry/Vector.h"
#include "../graphics/Sprite.h"
-using geometry::Point;
using geometry::Vector;
namespace battle {
-void MoveMenu::Render(SDL_Surface *screen, const geometry::Point<int> &position) {
+void MoveMenu::Render(SDL_Surface *screen, const geometry::Vector<int> &position) {
Vector<int> attackOffset(0, IconHeight());
Vector<int> changeOffset(0, 0);
Vector<int> runOffset(0, 2 * IconHeight());
#ifndef BATTLE_MOVEMENU_H_
#define BATTLE_MOVEMENU_H_
-#include "../geometry/Point.h"
+#include "../geometry/Vector.h"
#include "../graphics/Sprite.h"
namespace battle {
public:
void Select(Icon i) { selected = i; }
Icon Selected() const { return selected; }
- void Render(SDL_Surface *screen, const geometry::Point<int> &position);
+ void Render(SDL_Surface *screen, const geometry::Vector<int> &position);
int Width() const { return IconWidth(); }
int Height() const { return 3 * IconHeight(); }
#include "NumberAnimation.h"
-#include "../geometry/operators.h"
#include "../geometry/Vector.h"
using app::State;
-using geometry::Point;
using geometry::Vector;
using graphics::Animation;
using graphics::AnimationRunner;
return animation[0].GetSprite()->Height();
}
-void NumberAnimation::Draw(SDL_Surface *dest, const Point<int> &positionIn) const {
- Point<int> position(positionIn);
+void NumberAnimation::Draw(SDL_Surface *dest, const Vector<int> &positionIn) const {
+ Vector<int> position(positionIn);
Vector<int> step(animation[0].GetSprite()->Width(), 0);
if (number > 999) {
if (animation[0].Running()) {
#include "../graphics/Animation.h"
-#include "../geometry/Point.h"
+#include "../geometry/Vector.h"
namespace app {
class Application;
int Width() const;
int Height() const;
- void Draw(SDL_Surface *dest, const geometry::Point<int> &position) const;
+ void Draw(SDL_Surface *dest, const geometry::Vector<int> &position) const;
private:
int number;
#include "PartyLayout.h"
-using geometry::Point;
-using std::vector;
-
namespace battle {
}
#ifndef BATTLE_PARTYLAYOUT_H_
#define BATTLE_PARTYLAYOUT_H_
-#include "../geometry/Point.h"
+#include "../geometry/Vector.h"
#include <cassert>
#include <vector>
PartyLayout() { }
public:
- std::vector<geometry::Point<Uint8> >::size_type NumPositions() const { return positions.size(); }
+ std::vector<geometry::Vector<Uint8> >::size_type NumPositions() const { return positions.size(); }
template<class U>
- void CalculatePositions(U width, U height, std::vector<geometry::Point<U> > &dest) const {
+ void CalculatePositions(U width, U height, std::vector<geometry::Vector<U> > &dest) const {
dest.clear();
dest.reserve(positions.size());
- for (std::vector<geometry::Point<Uint8> >::const_iterator i(positions.begin()), end(positions.end()); i != end; ++i) {
- dest.push_back(geometry::Point<U>(
+ for (std::vector<geometry::Vector<Uint8> >::const_iterator i(positions.begin()), end(positions.end()); i != end; ++i) {
+ dest.push_back(geometry::Vector<U>(
i->X() * width / 255,
i->Y() * height / 223
));
}
}
template<class U>
- geometry::Point<U> CalculatePosition(std::vector<geometry::Point<Uint8> >::size_type index, U width, U height) const {
+ geometry::Vector<U> CalculatePosition(std::vector<geometry::Vector<Uint8> >::size_type index, U width, U height) const {
assert(index >= 0 && index < positions.size());
- return geometry::Point<U>(
+ return geometry::Vector<U>(
positions[index].X() * width / 255,
positions[index].Y() * height / 223
);
}
public:
- void AddPosition(const geometry::Point<Uint8> &p) {
+ void AddPosition(const geometry::Vector<Uint8> &p) {
positions.push_back(p);
}
private:
- std::vector<geometry::Point<Uint8> > positions;
+ std::vector<geometry::Vector<Uint8> > positions;
};
#include "SmallHeroTag.h"
#include "BattleState.h"
-#include "../geometry/operators.h"
#include "../geometry/Vector.h"
#include "../graphics/Font.h"
#include "../graphics/Frame.h"
#include "../graphics/Gauge.h"
-using geometry::Point;
using geometry::Vector;
using graphics::Font;
using graphics::Frame;
namespace battle {
-void SmallHeroTag::Render(SDL_Surface *screen, int width, int height, geometry::Point<int> position) const {
+void SmallHeroTag::Render(SDL_Surface *screen, int width, int height, geometry::Vector<int> position) const {
const Resources &r(battle->Res());
const Frame *frame((index == battle->MaxHeroes() - 1) ? r.lastSmallHeroTagFrame : r.smallHeroTagFrame);
const Font *font(r.normalFont);
#ifndef BATTLE_SMALLHEROTAG_H_
#define BATTLE_SMALLHEROTAG_H_
-#include "../geometry/Point.h"
+#include "../geometry/Vector.h"
#include <SDL.h>
SmallHeroTag(const BattleState *battle, int heroIndex)
: battle(battle), index(heroIndex) { }
- void Render(SDL_Surface *screen, int width, int height, geometry::Point<int> position) const;
+ void Render(SDL_Surface *screen, int width, int height, geometry::Vector<int> position) const;
private:
const BattleState *battle;
#include "../../common/Ikari.h"
#include "../../common/Item.h"
#include "../../common/Spell.h"
-#include "../../geometry/operators.h"
-#include "../../geometry/Point.h"
#include "../../graphics/Animation.h"
#include "../../graphics/Font.h"
#include "../../graphics/Frame.h"
using app::Application;
using app::Input;
-using geometry::Point;
using geometry::Vector;
using graphics::AnimationRunner;
using std::vector;
if (!titleBarText || !titleBarTimer.Running()) return;
int height(battle->Res().titleFrame->BorderHeight() * 2 + battle->Res().titleFont->CharHeight());
- battle->Res().titleFrame->Draw(screen, Point<int>(offset.X(), offset.Y()), battle->Width(), height);
+ battle->Res().titleFrame->Draw(screen, Vector<int>(offset.X(), offset.Y()), battle->Width(), height);
- Point<int> textPosition(
+ Vector<int> textPosition(
(battle->Width() - (std::strlen(titleBarText) * battle->Res().titleFont->CharWidth())) / 2,
battle->Res().titleFrame->BorderHeight());
battle->Res().titleFont->DrawString(titleBarText, screen, textPosition + offset);
if (!targetAnimation.Valid() || !targetAnimation.Running()) return;
const TargetSelection &ts(battle->CurrentAttackAttackChoice().Selection());
if (ts.TargetsHeroes()) {
- for (vector<Point<int> >::size_type i(0), end(battle->NumHeroes()); i < end; ++i) {
+ for (vector<Vector<int> >::size_type i(0), end(battle->NumHeroes()); i < end; ++i) {
if (ts.IsSelected(i)) {
targetAnimation.DrawCenter(screen, battle->HeroAt(i).Position() + offset);
}
}
} else {
- for (vector<Point<int> >::size_type i(0), end(battle->MaxMonsters()); i < end; ++i) {
+ for (vector<Vector<int> >::size_type i(0), end(battle->MaxMonsters()); i < end; ++i) {
if (ts.IsSelected(i)) {
targetAnimation.DrawCenter(screen, battle->MonsterAt(i).Position() + offset);
}
app::Timer<Uint32> titleBarTimer;
app::Timer<Uint32> targetAnimationTimer;
std::vector<NumberAnimation> numberAnimation;
- std::vector<geometry::Point<int> > numberPosition;
+ std::vector<geometry::Vector<int> > numberPosition;
int cursor;
};
#include "../BattleState.h"
#include "../../app/Application.h"
#include "../../app/Input.h"
-#include "../../geometry/operators.h"
-#include "../../geometry/Point.h"
+#include "../../geometry/Vector.h"
#include "../../graphics/Font.h"
#include "../../graphics/Frame.h"
using app::Application;
using app::Input;
-using geometry::Point;
using geometry::Vector;
namespace battle {
void RunState::RenderTitleBar(SDL_Surface *screen, const Vector<int> &offset) {
int height(battle->Res().titleFrame->BorderHeight() * 2 + battle->Res().titleFont->CharHeight());
- battle->Res().titleFrame->Draw(screen, Point<int>(offset.X(), offset.Y()), battle->Width(), height);
+ battle->Res().titleFrame->Draw(screen, Vector<int>(offset.X(), offset.Y()), battle->Width(), height);
- Point<int> textPosition(
+ Vector<int> textPosition(
(battle->Width() - (std::strlen(battle->Res().escapeText) * battle->Res().titleFont->CharWidth())) / 2,
battle->Res().titleFrame->BorderHeight());
battle->Res().titleFont->DrawString(battle->Res().escapeText, screen, textPosition + offset);
#include "../../app/Application.h"
#include "../../app/Input.h"
#include "../../common/Item.h"
-#include "../../geometry/operators.h"
#include <stdexcept>
using app::Application;
using app::Input;
using common::Item;
-using geometry::Point;
using geometry::Vector;
namespace battle {
}
void SelectAttackType::RenderMenu(SDL_Surface *screen, const Vector<int> &offset) {
- Point<int> position(
+ Vector<int> position(
(battle->Width() - battle->GetAttackTypeMenu().Width()) / 2,
battle->Height() - battle->GetAttackTypeMenu().Height() - battle->GetAttackTypeMenu().Height() / 2);
battle->GetAttackTypeMenu().Render(screen, position + offset);
#include "../../app/Input.h"
#include "../../common/Ikari.h"
#include "../../common/Item.h"
-#include "../../geometry/Point.h"
-#include "../../geometry/operators.h"
#include "../../graphics/Frame.h"
using app::Application;
using app::Input;
using common::Ikari;
-using geometry::Point;
using geometry::Vector;
using graphics::Frame;
void SelectIkari::RenderFrame(SDL_Surface *screen, const Vector<int> &offset) {
const Frame *frame(battle->Res().selectFrame);
- Point<int> position(frame->BorderWidth(), frame->BorderHeight());
+ Vector<int> position(frame->BorderWidth(), frame->BorderHeight());
int width(battle->Width() - 2 * frame->BorderWidth());
int height(battle->Res().normalFont->CharHeight() * 13);
frame->Draw(screen, position + offset, width, height);
void SelectIkari::RenderHeadline(SDL_Surface *screen, const Vector<int> &offset) {
const Resources &res(battle->Res());
- Point<int> position(
+ Vector<int> position(
2 * res.selectFrame->BorderWidth() + res.normalFont->CharWidth(),
2 * res.selectFrame->BorderHeight());
res.normalFont->DrawString(res.itemMenuHeadline, screen, position + offset);
void SelectIkari::RenderMenu(SDL_Surface *screen, const Vector<int> &offset) {
const Resources &res(battle->Res());
- Point<int> position(
+ Vector<int> position(
2 * res.selectFrame->BorderWidth() + res.normalFont->CharWidth(),
2 * res.selectFrame->BorderHeight() + 2 * res.normalFont->CharHeight());
battle->ActiveHero().IkariMenu().Draw(screen, position + offset);
#include "../../app/Application.h"
#include "../../app/Input.h"
#include "../../common/Item.h"
-#include "../../geometry/Point.h"
-#include "../../geometry/operators.h"
#include "../../graphics/Frame.h"
using app::Application;
using app::Input;
using common::Item;
-using geometry::Point;
using geometry::Vector;
using graphics::Frame;
void SelectItem::RenderFrame(SDL_Surface *screen, const Vector<int> &offset) {
const Frame *frame(battle->Res().selectFrame);
- Point<int> position(frame->BorderWidth(), frame->BorderHeight());
+ Vector<int> position(frame->BorderWidth(), frame->BorderHeight());
int width(battle->Width() - 2 * frame->BorderWidth());
int height(battle->Res().normalFont->CharHeight() * 13);
frame->Draw(screen, position + offset, width, height);
void SelectItem::RenderHeadline(SDL_Surface *screen, const Vector<int> &offset) {
const Resources &res(battle->Res());
- Point<int> position(
+ Vector<int> position(
2 * res.selectFrame->BorderWidth() + res.normalFont->CharWidth(),
2 * res.selectFrame->BorderHeight());
res.normalFont->DrawString(res.itemMenuHeadline, screen, position + offset);
void SelectItem::RenderMenu(SDL_Surface *screen, const Vector<int> &offset) {
const Resources &res(battle->Res());
- Point<int> position(
+ Vector<int> position(
2 * res.selectFrame->BorderWidth() + res.normalFont->CharWidth(),
2 * res.selectFrame->BorderHeight() + 2 * res.normalFont->CharHeight());
battle->ItemMenu().Draw(screen, position + offset);
#include "../MoveMenu.h"
#include "../../app/Application.h"
#include "../../app/Input.h"
-#include "../../geometry/operators.h"
using app::Application;
using app::Input;
-using geometry::Point;
using geometry::Vector;
namespace battle {
}
void SelectMoveAction::RenderMenu(SDL_Surface *screen, const Vector<int> &offset) {
- Point<int> position(
+ Vector<int> position(
(battle->Width() - battle->GetMoveMenu().Width()) / 2,
battle->Height() - battle->GetMoveMenu().Height() - battle->GetMoveMenu().Height() / 2);
battle->GetMoveMenu().Render(screen, position + offset);
#include "../../app/Application.h"
#include "../../app/Input.h"
#include "../../common/Spell.h"
-#include "../../geometry/operators.h"
-#include "../../geometry/Point.h"
#include "../../graphics/Frame.h"
using app::Application;
using app::Input;
using common::Spell;
-using geometry::Point;
using geometry::Vector;
using graphics::Frame;
void SelectSpell::RenderFrame(SDL_Surface *screen, const Vector<int> &offset) {
const Frame *frame(battle->Res().selectFrame);
- Point<int> position(frame->BorderWidth(), frame->BorderHeight());
+ Vector<int> position(frame->BorderWidth(), frame->BorderHeight());
int width(battle->Width() - 2 * frame->BorderWidth());
int height(battle->Res().normalFont->CharHeight() * 13);
frame->Draw(screen, position + offset, width, height);
void SelectSpell::RenderHeadline(SDL_Surface *screen, const Vector<int> &offset) {
const Resources &res(battle->Res());
- Point<int> position(
+ Vector<int> position(
2 * res.selectFrame->BorderWidth() + res.normalFont->CharWidth(),
2 * res.selectFrame->BorderHeight());
res.normalFont->DrawString(res.spellMenuHeadline, screen, position + offset);
void SelectSpell::RenderMenu(SDL_Surface *screen, const Vector<int> &offset) {
const Resources &res(battle->Res());
- Point<int> position(
+ Vector<int> position(
2 * res.selectFrame->BorderWidth() + res.normalFont->CharWidth(),
2 * res.selectFrame->BorderHeight() + 2 * res.normalFont->CharHeight());
battle->ActiveHero().SpellMenu().Draw(screen, position + offset);
#include "../BattleState.h"
#include "../../app/Application.h"
#include "../../app/Input.h"
-#include "../../geometry/operators.h"
-#include "../../geometry/Point.h"
using app::Application;
using app::Input;
-using geometry::Point;
using geometry::Vector;
using std::vector;
Vector<int> cursorOffset(cursorIcon->Width() / -2, cursorIcon->Height());
// offset the indicator by 1/8th to the right and top
Vector<int> indicatorOffset(cursorOffset + Vector<int>(cursorIcon->Width() / 8, cursorIcon->Height() / -8));
- vector<Point<int> > positions;
+ vector<Vector<int> > positions;
if (selection->TargetsMonsters()) {
for (int i(0), end(battle->MaxMonsters()); i < end; ++i) {
positions.push_back(battle->MonsterAt(i).Position());
}
}
if (flipFlop) {
- for (vector<Point<int> >::size_type i(0); i < positions.size(); ++i) {
+ for (vector<Vector<int> >::size_type i(0); i < positions.size(); ++i) {
if (selection->IsSelected(i)) {
cursorIcon->DrawTopRight(screen, positions[i] + indicatorOffset + offset);
}
#include "../BattleState.h"
#include "../../app/Application.h"
#include "../../app/Input.h"
-#include "../../geometry/operators.h"
-#include "../../geometry/Point.h"
using app::Application;
using app::Input;
-using geometry::Point;
using geometry::Vector;
using std::vector;
// offset the cursor by 1/8th to the left and bottom
Vector<int> cursorOffset(battle->Res().swapCursor->Width() / -8, battle->Res().swapCursor->Height() / 8);
Vector<int> indicatorOffset(0, 0);
- vector<Point<int> > positions;
+ vector<Vector<int> > positions;
for (int i(0), end(battle->NumHeroes()); i < end; ++i) {
Vector<int> positionCorrection(battle->Res().swapCursor->Width() / 2, battle->HeroTagAt(i).HeroSprite()->Height() - battle->Res().swapCursor->Height() / 2);
// indicator offsets are inverted for heroes
positions.push_back(battle->HeroTagPositionAt(i) + battle->HeroTagAt(i).HeroOffset() + positionCorrection);
}
if (flipFlop) {
- for (vector<Point<int> >::size_type i(0); i < positions.size(); ++i) {
+ for (vector<Vector<int> >::size_type i(0); i < positions.size(); ++i) {
if (selected == int(i)) {
battle->Res().swapCursor->DrawTopRight(screen, positions[i] + offset);
}
+++ /dev/null
-/*
- * Point.h
- *
- * Created on: Aug 5, 2012
- * Author: holy
- */
-
-#ifndef GEOMETRY_POINT_H_
-#define GEOMETRY_POINT_H_
-
-namespace geometry {
-
-template<class T>
-class Point {
-
-public:
- Point() : x(0), y(0) { }
- Point(T x, T y) : x(x), y(y) { }
-
-public:
- T X() const { return x; }
- T Y() const { return y; }
-
-private:
- T x, y;
-
-};
-
-}
-
-#endif /* GEOMETRY_POINT_H_ */
#ifndef GEOMETRY_VECTOR_H_
#define GEOMETRY_VECTOR_H_
+#include <ostream>
+
namespace geometry {
template<class Scalar>
};
+
+template<class T>
+inline Vector<T> operator +(const Vector<T> &lhs, const Vector<T> &rhs) {
+ return Vector<T>(lhs.X() + rhs.X(), lhs.Y() + rhs.Y());
+}
+
+template<class T>
+inline Vector<T> &operator +=(Vector<T> &lhs, const Vector<T> &rhs) {
+ return lhs = lhs + rhs;
+}
+
+template<class T>
+inline Vector<T> operator -(const Vector<T> &lhs, const Vector<T> &rhs) {
+ return Vector<T>(lhs.X() - rhs.X(), lhs.Y() - rhs.Y());
+}
+
+template<class T>
+inline Vector<T> &operator -=(Vector<T> &lhs, const Vector<T> &rhs) {
+ return lhs = lhs - rhs;
+}
+
+template<class T>
+inline Vector<T> operator -(const Vector<T> &v) {
+ return Vector<T>(-v.X(), -v.Y());
+}
+
+template<class T>
+inline Vector<T> operator *(const Vector<T> &v, T s) {
+ return Vector<T>(v.X() * s, v.Y() * s);
+}
+template<class T>
+inline Vector<T> operator *(T s, const Vector<T> &v) {
+ return Vector<T>(s * v.X(), s * v.Y());
+}
+
+template<class T>
+inline Vector<T> operator /(const Vector<T> &v, T s) {
+ return Vector<T>(v.X() / s, v.Y() / s);
+}
+
+template<class T>
+inline std::ostream &operator <<(std::ostream &out, const Vector<T> &v) {
+ out << '<' << v.X() << ", " << v.Y() << '>';
+ return out;
+}
+
}
#endif /* GEOMETRY_VECTOR_H_ */
+++ /dev/null
-/*
- * operators.h
- *
- * Created on: Aug 6, 2012
- * Author: holy
- */
-
-#ifndef GEOMETRY_OPERATORS_H_
-#define GEOMETRY_OPERATORS_H_
-
-#include "Point.h"
-#include "Vector.h"
-
-#include <ostream>
-
-namespace geometry {
-
-template<class T>
-inline Vector<T> operator +(const Vector<T> &lhs, const Vector<T> &rhs) {
- return Vector<T>(lhs.X() + rhs.X(), lhs.Y() + rhs.Y());
-}
-template<class T>
-inline Point<T> operator +(const Point<T> &lhs, const Vector<T> &rhs) {
- return Point<T>(lhs.X() + rhs.X(), lhs.Y() + rhs.Y());
-}
-
-template<class T>
-inline Vector<T> &operator +=(Vector<T> &lhs, const Vector<T> &rhs) {
- return lhs = lhs + rhs;
-}
-template<class T>
-inline Point<T> &operator +=(Point<T> &lhs, const Vector<T> &rhs) {
- return lhs = lhs + rhs;
-}
-
-template<class T>
-inline Vector<T> operator -(const Vector<T> &lhs, const Vector<T> &rhs) {
- return Vector<T>(lhs.X() - rhs.X(), lhs.Y() - rhs.Y());
-}
-template<class T>
-inline Point<T> operator -(const Point<T> &lhs, const Vector<T> &rhs) {
- return Point<T>(lhs.X() - rhs.X(), lhs.Y() - rhs.Y());
-}
-
-template<class T>
-inline Vector<T> &operator -=(Vector<T> &lhs, const Vector<T> &rhs) {
- return lhs = lhs - rhs;
-}
-template<class T>
-inline Point<T> &operator -=(Point<T> &lhs, const Vector<T> &rhs) {
- return lhs = lhs - rhs;
-}
-
-template<class T>
-inline Vector<T> operator -(const Vector<T> &v) {
- return Vector<T>(-v.X(), -v.Y());
-}
-
-template<class T>
-inline std::ostream &operator <<(std::ostream &out, const Point<T> &p) {
- out << '(' << p.X() << ", " << p.Y() << ')';
- return out;
-}
-template<class T>
-inline std::ostream &operator <<(std::ostream &out, const Vector<T> &v) {
- out << '<' << v.X() << ", " << v.Y() << '>';
- return out;
-}
-
-}
-
-#endif /* GEOMETRY_OPERATORS_H_ */
#include "../app/Application.h"
#include "../app/State.h"
#include "../app/Timer.h"
-#include "../geometry/operators.h"
-#include "../geometry/Point.h"
#include "../geometry/Vector.h"
#include <SDL.h>
void ChangeSprite(const Sprite *s) { sprite = s; }
const Sprite *GetSprite() const { return sprite; }
- void Draw(SDL_Surface *dest, geometry::Point<int> position) const {
+ void Draw(SDL_Surface *dest, geometry::Vector<int> position) const {
sprite->Draw(dest, position + animation->Offset(Frame()), animation->Col(Frame()) + ColOffset(), animation->Row(Frame()) + RowOffset());
}
- void DrawTopRight(SDL_Surface *dest, geometry::Point<int> position) const {
+ void DrawTopRight(SDL_Surface *dest, geometry::Vector<int> position) const {
geometry::Vector<int> offset(-sprite->Width(), 0);
Draw(dest, position + offset);
}
- void DrawCenter(SDL_Surface *dest, geometry::Point<int> position) const {
+ void DrawCenter(SDL_Surface *dest, geometry::Vector<int> position) const {
geometry::Vector<int> offset(-sprite->Width() / 2, -sprite->Height() / 2);
Draw(dest, position + offset);
}
- void DrawCenterBottom(SDL_Surface *dest, geometry::Point<int> position) const {
+ void DrawCenterBottom(SDL_Surface *dest, geometry::Vector<int> position) const {
geometry::Vector<int> offset(-sprite->Width() / 2, -sprite->Height());
Draw(dest, position + offset);
}
#include "Font.h"
-#include "../geometry/operators.h"
-#include "../geometry/Vector.h"
-
#include <cmath>
-using geometry::Point;
using geometry::Vector;
using std::pow;
namespace graphics {
-void Font::DrawChar(char c, SDL_Surface *dest, const Point<int> &position) const {
+void Font::DrawChar(char c, SDL_Surface *dest, const Vector<int> &position) const {
int col(colOffset + (c % 0x10));
int row(rowOffset + (c / 0x10));
sprite->Draw(dest, position, col, row);
}
-void Font::DrawString(const char *s, SDL_Surface *dest, const Point<int> &positionIn, int maxChars) const {
- Point<int> position(positionIn);
+void Font::DrawString(const char *s, SDL_Surface *dest, const Vector<int> &positionIn, int maxChars) const {
+ Vector<int> position(positionIn);
Vector<int> step(CharWidth(), 0);
for (int i(0); s[i] && (maxChars <= 0 || i < maxChars); ++i, position += step) {
DrawChar(s[i], dest, position);
}
}
-void Font::DrawDigit(int digit, SDL_Surface *dest, const Point<int> &position) const {
+void Font::DrawDigit(int digit, SDL_Surface *dest, const Vector<int> &position) const {
DrawChar(digit + 0x30, dest, position);
}
-void Font::DrawNumber(int numberIn, SDL_Surface *dest, const Point<int> &positionIn, int digits) const {
+void Font::DrawNumber(int numberIn, SDL_Surface *dest, const Vector<int> &positionIn, int digits) const {
int number(numberIn);
if (digits > 0 && numberIn >= pow(10.0, digits)) {
numberIn = pow(10.0, digits) - 1;
}
- Point<int> position(positionIn);
+ Vector<int> position(positionIn);
Vector<int> step(sprite->Width(), 0);
if (digits > 0) {
#define GRAPHICS_FONT_H_
#include "Sprite.h"
-#include "../geometry/Point.h"
+#include "../geometry/Vector.h"
#include <SDL.h>
public:
int CharWidth() const { return sprite->Width(); }
int CharHeight() const { return sprite->Height(); }
- void DrawChar(char c, SDL_Surface *dest, const geometry::Point<int> &position) const;
- void DrawString(const char *s, SDL_Surface *dest, const geometry::Point<int> &position, int maxChars = 0) const;
- void DrawDigit(int d, SDL_Surface *dest, const geometry::Point<int> &position) const;
- void DrawNumber(int n, SDL_Surface *dest, const geometry::Point<int> &position, int digits = 0) const;
+ void DrawChar(char c, SDL_Surface *dest, const geometry::Vector<int> &position) const;
+ void DrawString(const char *s, SDL_Surface *dest, const geometry::Vector<int> &position, int maxChars = 0) const;
+ void DrawDigit(int d, SDL_Surface *dest, const geometry::Vector<int> &position) const;
+ void DrawNumber(int n, SDL_Surface *dest, const geometry::Vector<int> &position, int digits = 0) const;
private:
const Sprite *sprite;
#include "Frame.h"
-using geometry::Point;
+using geometry::Vector;
namespace graphics {
// TODO: maybe create a cache for frames?
-void Frame::Draw(SDL_Surface *dest, const Point<int> &position, int width, int height) const {
+void Frame::Draw(SDL_Surface *dest, const Vector<int> &position, int width, int height) const {
// top-left corner
SDL_Rect srcRect;
srcRect.x = xOffset;
#ifndef GRAPHICS_FRAME_H_
#define GRAPHICS_FRAME_H_
-#include "../geometry/Point.h"
+#include "../geometry/Vector.h"
#include <SDL.h>
int MinHeight() const { return 2 * borderHeight; }
int BorderWidth() const { return borderWidth; }
int BorderHeight() const { return borderHeight; }
- void Draw(SDL_Surface *dest, const geometry::Point<int> &position, int width, int height) const;
+ void Draw(SDL_Surface *dest, const geometry::Vector<int> &position, int width, int height) const;
private:
SDL_Surface *surface;
#include "Gauge.h"
-using geometry::Point;
+using geometry::Vector;
namespace graphics {
-void Gauge::Draw(SDL_Surface *dest, const Point<int> &position, int width, Uint8 fill) const {
+void Gauge::Draw(SDL_Surface *dest, const Vector<int> &position, int width, Uint8 fill) const {
SDL_Rect srcRect, destRect;
int filledWidth = fill * (width - startWidth - endWidth) / 255;
#ifndef GRAPHICS_GAUGE_H_
#define GRAPHICS_GAUGE_H_
-#include "../geometry/Point.h"
+#include "../geometry/Vector.h"
#include <SDL.h>
public:
int MinWidth() const { return startWidth + endWidth; }
int Height() const { return height; }
- void Draw(SDL_Surface *dest, const geometry::Point<int> &position, int width, Uint8 fill) const;
+ void Draw(SDL_Surface *dest, const geometry::Vector<int> &position, int width, Uint8 fill) const;
private:
SDL_Surface *surface;
#include "Font.h"
#include "Sprite.h"
-#include "../geometry/operators.h"
-#include "../geometry/Point.h"
#include "../geometry/Vector.h"
#include <vector>
void Reserve(int n) { entries.reserve(n); }
void Clear() { entries.clear(); }
- void Draw(SDL_Surface *dest, const geometry::Point<int> &position) const;
+ void Draw(SDL_Surface *dest, const geometry::Vector<int> &position) const;
private:
int GetRow(int index) const { return index / cols; }
template<class T>
-void Menu<T>::Draw(SDL_Surface *dest, const geometry::Point<int> &position) const {
+void Menu<T>::Draw(SDL_Surface *dest, const geometry::Vector<int> &position) const {
int start(topRow * cols);
int slots(rows * cols);
int items(entries.size() - start);
#include "Sprite.h"
-using geometry::Point;
+using geometry::Vector;
namespace graphics {
-void Sprite::Draw(SDL_Surface *dest, const Point<int> &position, int col, int row) const {
+void Sprite::Draw(SDL_Surface *dest, const Vector<int> &position, int col, int row) const {
SDL_Rect srcRect, destRect;
srcRect.x = xOffset + col * Width();
srcRect.y = yOffset + row * Height();
#ifndef GRAPHICS_SPRITE_H_
#define GRAPHICS_SPRITE_H_
-#include "../geometry/operators.h"
-#include "../geometry/Point.h"
#include "../geometry/Vector.h"
#include <SDL.h>
public:
int Width() const { return width; }
int Height() const { return height; }
- void Draw(SDL_Surface *dest, const geometry::Point<int> &position, int col = 0, int row = 0) const;
- void DrawTopRight(SDL_Surface *dest, const geometry::Point<int> &position, int col = 0, int row = 0) const {
+ void Draw(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const;
+ void DrawTopRight(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const {
geometry::Vector<int> offset(-Width(), 0);
Draw(dest, position + offset, col, row);
}
- void DrawCenter(SDL_Surface *dest, const geometry::Point<int> &position, int col = 0, int row = 0) const {
+ void DrawCenter(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const {
geometry::Vector<int> offset(-Width() / 2, -Height() / 2);
Draw(dest, position + offset, col, row);
}
- void DrawCenterBottom(SDL_Surface *dest, const geometry::Point<int> &position, int col = 0, int row = 0) const {
+ void DrawCenterBottom(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const {
geometry::Vector<int> offset(-Width() / 2, -Height());
Draw(dest, position + offset, col, row);
}
#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"
using common::Inventory;
using common::Item;
using common::Spell;
-using geometry::Point;
using geometry::Vector;
using graphics::ComplexAnimation;
using graphics::Font;
// 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 monsterSprite(monsterImg, 64, 64);