void BattleState::RenderMonsters(SDL_Surface *screen, const Vector<int> &offset) {
for (vector<Monster>::size_type i(0), end(monsters.size()); i < end; ++i) {
- monsters[i].Sprite()->DrawCenterBottom(screen, monsterPositions[i] + offset);
+ monsters[i].Sprite()->DrawCenter(screen, monsterPositions[i] + offset);
}
}
void BattleState::RenderHeroes(SDL_Surface *screen, const Vector<int> &offset) {
for (int i(0); i < numHeroes; ++i) {
if (heroes[i].AttackAnimation() && heroes[i].AttackAnimation()->Running()) {
- heroes[i].AttackAnimation()->DrawCenterBottom(screen, heroesPositions[i] + offset);
+ heroes[i].AttackAnimation()->DrawCenter(screen, heroesPositions[i] + offset);
} else if (heroes[i].SpellAnimation() && heroes[i].SpellAnimation()->Running()) {
- heroes[i].SpellAnimation()->DrawCenterBottom(screen, heroesPositions[i] + offset);
+ heroes[i].SpellAnimation()->DrawCenter(screen, heroesPositions[i] + offset);
} else {
int row(heroes[i].Health() > 0 ? 0 : 2);
- heroes[i].Sprite()->DrawCenterBottom(screen, heroesPositions[i] + offset, 1, row);
+ heroes[i].Sprite()->DrawCenter(screen, heroesPositions[i] + offset, 1, row);
}
}
}
}
// hero
- HeroSprite()->Draw(screen, position + HeroOffset(), 0, battle->HeroAt(index).Health() > 0 ? 0 : 2);
+ HeroSprite()->DrawCenter(screen, position + HeroOffset(), 0, battle->HeroAt(index).Health() > 0 ? 0 : 2);
}
Vector<int> HeroTag::HeroOffset() const {
return Vector<int>(
- (index % 2) ? battle->Res().normalFont->CharWidth() : 10 * battle->Res().normalFont->CharWidth(),
- battle->Res().normalFont->CharWidth());
+ ((index % 2) ? battle->Res().normalFont->CharWidth() : 10 * battle->Res().normalFont->CharWidth()) + HeroSprite()->Width() / 2,
+ battle->Res().normalFont->CharWidth() + HeroSprite()->Height() / 2);
}
}
void SelectTarget::RenderCursors(SDL_Surface *screen, const geometry::Vector<int> &offset) {
// TODO: this should be related to the enemy's width
- // offset the cursor by 1/8th to the left and bottom
- Vector<int> cursorOffset(cursorIcon->Width() / -8, cursorIcon->Height() / 8);
- Vector<int> indicatorOffset(0, 0);
+ 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;
if (selection->TargetsEnemies()) {
for (vector<Point<int> >::const_iterator i(battle->MonsterPositions().begin()), end(battle->MonsterPositions().end()); i != end; ++i) {
}
} else {
for (int i(0), end(battle->NumHeroes()); i < end; ++i) {
- Vector<int> positionCorrection(cursorIcon->Width() / 2, battle->HeroTagAt(i).HeroSprite()->Height() - cursorIcon->Height() / 2);
- // indicator offsets are inverted for heroes
- positionCorrection -= cursorOffset;
- positions.push_back(battle->HeroTagPositionAt(i) + battle->HeroTagAt(i).HeroOffset() + positionCorrection);
+ positions.push_back(battle->HeroTagPositionAt(i) + battle->HeroTagAt(i).HeroOffset());
}
}
if (flipFlop) {
for (vector<Point<int> >::size_type i(0); i < positions.size(); ++i) {
if (selection->IsSelected(i)) {
- cursorIcon->DrawTopRight(screen, positions[i] + offset);
+ cursorIcon->DrawTopRight(screen, positions[i] + indicatorOffset + offset);
}
}
}
// temporary test data
SDL_Surface *bg(IMG_Load("test-data/battle-bg.png"));
PartyLayout monstersLayout;
- monstersLayout.AddPosition(Point<Uint8>(88, 104));
- monstersLayout.AddPosition(Point<Uint8>(128, 104));
- monstersLayout.AddPosition(Point<Uint8>(168, 104));
- monstersLayout.AddPosition(Point<Uint8>(208, 104));
+ monstersLayout.AddPosition(Point<Uint8>(88, 88));
+ monstersLayout.AddPosition(Point<Uint8>(128, 88));
+ monstersLayout.AddPosition(Point<Uint8>(168, 88));
+ monstersLayout.AddPosition(Point<Uint8>(208, 88));
PartyLayout heroesLayout;
- heroesLayout.AddPosition(Point<Uint8>(48, 152));
- heroesLayout.AddPosition(Point<Uint8>(128, 152));
- heroesLayout.AddPosition(Point<Uint8>(80, 168));
- heroesLayout.AddPosition(Point<Uint8>(160, 168));
+ heroesLayout.AddPosition(Point<Uint8>(48, 136));
+ heroesLayout.AddPosition(Point<Uint8>(128, 136));
+ heroesLayout.AddPosition(Point<Uint8>(80, 152));
+ heroesLayout.AddPosition(Point<Uint8>(160, 152));
SDL_Surface *monsterImg(IMG_Load("test-data/monster.png"));
Sprite dummySprite(monsterImg, 64, 64);