../src/battle/AttackTypeMenu.cpp \
../src/battle/BattleState.cpp \
../src/battle/Hero.cpp \
+../src/battle/HeroTag.cpp \
../src/battle/Monster.cpp \
../src/battle/PartyLayout.cpp
./src/battle/AttackTypeMenu.o \
./src/battle/BattleState.o \
./src/battle/Hero.o \
+./src/battle/HeroTag.o \
./src/battle/Monster.o \
./src/battle/PartyLayout.o
./src/battle/AttackTypeMenu.d \
./src/battle/BattleState.d \
./src/battle/Hero.d \
+./src/battle/HeroTag.d \
./src/battle/Monster.d \
./src/battle/PartyLayout.d
../src/battle/AttackTypeMenu.cpp \
../src/battle/BattleState.cpp \
../src/battle/Hero.cpp \
+../src/battle/HeroTag.cpp \
../src/battle/Monster.cpp \
../src/battle/PartyLayout.cpp
./src/battle/AttackTypeMenu.o \
./src/battle/BattleState.o \
./src/battle/Hero.o \
+./src/battle/HeroTag.o \
./src/battle/Monster.o \
./src/battle/PartyLayout.o
./src/battle/AttackTypeMenu.d \
./src/battle/BattleState.d \
./src/battle/Hero.d \
+./src/battle/HeroTag.d \
./src/battle/Monster.d \
./src/battle/PartyLayout.d
}
}
-void AttackTypeMenu::Render(SDL_Surface *screen, const geometry::Point<int> ¢er) {
- Vector<int> swordOffset(icons->Width() / -2, icons->Height() / -2);
- Vector<int> magicOffset(swordOffset.X(), swordOffset.Y() - icons->Height());
- Vector<int> defendOffset(swordOffset.X() + icons->Width(), swordOffset.Y());
- Vector<int> ikariOffset(swordOffset.X(), swordOffset.Y() + icons->Height());
- Vector<int> itemOffset(swordOffset.X() - icons->Width(), swordOffset.Y());
-
- icons->Draw(screen, center + swordOffset, SWORD, (selected == SWORD) ? 1 : 0);
- icons->Draw(screen, center + magicOffset, MAGIC, (selected == MAGIC) ? 1 : 0);
- icons->Draw(screen, center + defendOffset, DEFEND, (selected == DEFEND) ? 1 : 0);
- icons->Draw(screen, center + ikariOffset, IKARI, (selected == IKARI) ? 1 : 0);
- icons->Draw(screen, center + itemOffset, ITEM, (selected == ITEM) ? 1 : 0);
+void AttackTypeMenu::Render(SDL_Surface *screen, const geometry::Point<int> &position) {
+ Vector<int> swordOffset(IconWidth(), IconHeight());
+ Vector<int> magicOffset(IconWidth(), 0);
+ Vector<int> defendOffset(2 * IconWidth(), IconHeight());
+ Vector<int> ikariOffset(IconWidth(), 2 * IconHeight());
+ Vector<int> itemOffset(0, IconHeight());
+
+ icons->Draw(screen, position + swordOffset, SWORD, (selected == SWORD) ? 1 : 0);
+ icons->Draw(screen, position + magicOffset, MAGIC, (selected == MAGIC) ? 1 : 0);
+ icons->Draw(screen, position + defendOffset, DEFEND, (selected == DEFEND) ? 1 : 0);
+ icons->Draw(screen, position + ikariOffset, IKARI, (selected == IKARI) ? 1 : 0);
+ icons->Draw(screen, position + itemOffset, ITEM, (selected == ITEM) ? 1 : 0);
}
}
#define BATTLE_ATTACKTYPEMENU_H_
namespace app { class Input; }
-namespace graphics { class Sprite; }
#include "../geometry/Point.h"
+#include "../graphics/Sprite.h"
#include <SDL.h>
public:
void ReadInput(const app::Input &);
Icon Selected() const { return selected; }
- void Render(SDL_Surface *screen, const geometry::Point<int> ¢er);
+ void Render(SDL_Surface *screen, const geometry::Point<int> &position);
+
+ int Width() const { return 3 * IconWidth(); }
+ int Height() const { return 3 * IconHeight(); }
+ int IconWidth() const { return icons->Width(); }
+ int IconHeight() const { return icons->Height(); }
private:
const graphics::Sprite *icons;
void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) {
monstersLayout->CalculatePositions(background->w, background->h, monsterPositions);
heroesLayout->CalculatePositions(background->w, background->h, heroesPositions);
+ for (vector<Hero>::size_type i(0), end(heroes.size()); i < end; ++i) {
+ heroTags.push_back(HeroTag(&heroes[i], HeroTag::Alignment((i + 1) % 2)));
+ }
}
void BattleState::ExitState() {
RenderBackground(screen, offset);
RenderMonsters(screen, offset);
// RenderHeroes(screen, offset);
- attackTypeMenu.Render(screen, Point<int>(background->w / 2, background->h * 3 / 4));
+ RenderHeroTags(screen, offset);
+ RenderAttackTypeMenu(screen, offset);
}
void BattleState::RenderBackground(SDL_Surface *screen, const Vector<int> &offset) {
}
}
+void BattleState::RenderHeroTags(SDL_Surface *screen, const Vector<int> &offset) {
+ int uiHeight(background->h / 2), uiOffset(uiHeight);
+ int tagHeight((uiHeight - attackTypeMenu.IconHeight()) / 2);
+ int tagWidth((background->w - attackTypeMenu.IconWidth()) / 2);
+
+ Point<int> tagPosition[4];
+ tagPosition[0] = Point<int>(0, uiOffset);
+ tagPosition[1] = Point<int>(tagWidth + attackTypeMenu.IconWidth(), uiOffset);
+ tagPosition[2] = Point<int>(0, uiOffset + tagHeight + attackTypeMenu.IconHeight());
+ tagPosition[3] = Point<int>(tagWidth + attackTypeMenu.IconWidth(), uiOffset + tagHeight + attackTypeMenu.IconHeight());
+
+ for (vector<HeroTag>::size_type i(0), end(heroTags.size()); i < end; ++i) {
+ heroTags[i].Render(screen, tagWidth, tagHeight, tagPosition[i] + offset);
+ }
+}
+
+void BattleState::RenderAttackTypeMenu(SDL_Surface *screen, const Vector<int> &offset) {
+ Point<int> position(
+ (background->w - attackTypeMenu.Width()) / 2,
+ (background->h * 3 / 4) - (attackTypeMenu.Height() / 2));
+ attackTypeMenu.Render(screen, position + offset);
+}
+
}
#include "AttackTypeMenu.h"
#include "Hero.h"
+#include "HeroTag.h"
#include "Monster.h"
#include "../app/State.h"
#include "../geometry/Point.h"
void RenderBackground(SDL_Surface *screen, const geometry::Vector<int> &offset);
void RenderMonsters(SDL_Surface *screen, const geometry::Vector<int> &offset);
void RenderHeroes(SDL_Surface *screen, const geometry::Vector<int> &offset);
+ void RenderHeroTags(SDL_Surface *screen, const geometry::Vector<int> &offset);
+ void RenderAttackTypeMenu(SDL_Surface *screen, const geometry::Vector<int> &offset);
private:
SDL_Surface *background;
std::vector<geometry::Point<int> > heroesPositions;
std::vector<Monster> monsters;
std::vector<Hero> heroes;
+ std::vector<HeroTag> heroTags;
};
--- /dev/null
+/*
+ * HeroTag.cpp
+ *
+ * Created on: Aug 6, 2012
+ * Author: holy
+ */
+
+#include "HeroTag.h"
+
+using geometry::Point;
+
+namespace battle {
+
+void HeroTag::Render(SDL_Surface *screen, int width, int height, Point<int> position) const {
+ SDL_Rect destRect;
+ destRect.x = position.X();
+ destRect.y = position.Y();
+ destRect.w = width;
+ destRect.h = height;
+
+ destRect.x += 1;
+ destRect.y += 1;
+ destRect.w -= 2;
+ destRect.h -= 2;
+ SDL_FillRect(screen, &destRect, SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF));
+
+ destRect.x += 1;
+ destRect.y += 1;
+ destRect.w -= 2;
+ destRect.h -= 2;
+ SDL_FillRect(screen, &destRect, SDL_MapRGB(screen->format, 0, 0, 0));
+}
+
+}
--- /dev/null
+/*
+ * HeroTag.h
+ *
+ * Created on: Aug 6, 2012
+ * Author: holy
+ */
+
+#ifndef BATTLE_HEROTAG_H_
+#define BATTLE_HEROTAG_H_
+
+#include "../geometry/Point.h"
+
+#include <SDL.h>
+
+namespace battle {
+
+class Hero;
+
+class HeroTag {
+
+public:
+ enum Alignment {
+ LEFT,
+ RIGHT
+ };
+
+public:
+ HeroTag(const Hero *hero, Alignment align) : hero(hero), align(align) { }
+ ~HeroTag() { }
+
+public:
+ void Render(SDL_Surface *screen, int width, int height, geometry::Point<int> position) const;
+
+private:
+ const Hero *hero;
+ Alignment align;
+
+};
+
+}
+
+#endif /* BATTLE_HEROTAG_H_ */