void BattleState::OnResize(int w, int h) {
-
+ offset = Vector<int>(
+ (w - background->w) / 2,
+ (h - background->h) / 2);
}
smallHeroTagPositions[2] = Vector<int>(xOffset + tagWidth, yOffset);
smallHeroTagPositions[3] = Vector<int>(xOffset + 3 * tagWidth, yOffset);
+ OnResize(screen->w, screen->h);
+
itemMenu = *res->itemMenuProperties;
LoadInventory();
ClearAllAttacks();
void BattleState::Render(SDL_Surface *screen) {
assert(screen);
- Vector<int> offset(CalculateScreenOffset(screen));
- RenderBackground(screen, offset);
- RenderMonsters(screen, offset);
+ RenderBackground(screen);
+ RenderMonsters(screen);
}
-void BattleState::RenderBackground(SDL_Surface *screen, const Vector<int> &offset) {
+void BattleState::RenderBackground(SDL_Surface *screen) {
assert(screen);
// black for now
SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
SDL_BlitSurface(background, 0, screen, &destRect);
}
-void BattleState::RenderMonsters(SDL_Surface *screen, const Vector<int> &offset) {
+void BattleState::RenderMonsters(SDL_Surface *screen) {
assert(screen);
for (vector<Monster>::size_type i(0), end(monsters.size()); i < end; ++i) {
if (MonsterPositionOccupied(i)) {
}
}
-void BattleState::RenderHeroes(SDL_Surface *screen, const Vector<int> &offset) {
+void BattleState::RenderHeroes(SDL_Surface *screen) {
assert(screen);
for (int i(0); i < numHeroes; ++i) {
if (heroes[i].GetAnimation().Running()) {
}
}
-void BattleState::RenderCapsule(SDL_Surface *screen, const Vector<int> &offset) {
+void BattleState::RenderCapsule(SDL_Surface *screen) {
if (!capsule.Active() || capsule.Health() <= 0) return;
if (capsule.GetAnimation().Running()) {
capsule.GetAnimation().DrawCenter(screen, capsule.Position() + offset);
}
}
-void BattleState::RenderHeroTags(SDL_Surface *screen, const Vector<int> &offset) {
+void BattleState::RenderHeroTags(SDL_Surface *screen) {
assert(screen);
int tagHeight(attackTypeMenu.Height());
int tagWidth(attackTypeMenu.Width() * 2 + attackTypeMenu.Width() / 2);
}
}
-void BattleState::RenderSmallHeroTags(SDL_Surface *screen, const Vector<int> &offset) {
+void BattleState::RenderSmallHeroTags(SDL_Surface *screen) {
assert(screen);
int tagHeight(res->normalFont->CharHeight() * 4 + res->smallHeroTagFrame->BorderHeight() * 2);
int tagWidth(res->normalFont->CharWidth() * 6 + res->smallHeroTagFrame->BorderWidth() * 2);