+ assert(screen);
+ RenderBackground(screen);
+ RenderMonsters(screen);
+}
+
+void BattleState::RenderBackground(SDL_Surface *screen) {
+ assert(screen);
+ // black for now
+ SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
+ SDL_Rect destRect;
+ destRect.x = offset.X();
+ destRect.y = offset.Y();
+ destRect.w = background->w;
+ destRect.h = background->h;
+ SDL_BlitSurface(background, 0, screen, &destRect);
+}
+
+void BattleState::RenderMonsters(SDL_Surface *screen) {
+ assert(screen);
+ for (vector<Monster>::size_type i(0), end(battle.NumMonsters()); i < end; ++i) {
+ if (battle.MonsterPositionOccupied(i)) {
+ Monster &monster(battle.MonsterAt(i));
+ if (monster.GetAnimation().Running()) {
+ monster.GetAnimation().DrawCenter(screen, monster.Position() + offset);
+ } else {
+ monster.Sprite()->DrawCenter(screen, monster.Position() + offset);
+ }
+ }
+ }
+}
+
+void BattleState::RenderHeroes(SDL_Surface *screen) {
+ assert(screen);
+ for (int i(0); i < NumHeroes(); ++i) {
+ Hero &hero(battle.HeroAt(i));
+ if (hero.GetAnimation().Running()) {
+ hero.GetAnimation().DrawCenter(screen, hero.Position() + offset);
+ } else {
+ int row(hero.Health() > 0 ? 0 : 2);
+ hero.Sprite()->DrawCenter(screen, hero.Position() + offset, 1, row);
+ }
+ }
+}
+
+void BattleState::RenderCapsule(SDL_Surface *screen) {
+ const Capsule &capsule(battle.GetCapsule());
+ if (!capsule.Active() || capsule.Health() <= 0) return;
+ if (capsule.GetAnimation().Running()) {
+ capsule.GetAnimation().DrawCenter(screen, capsule.Position() + offset);
+ } else {
+ capsule.Sprite()->DrawCenter(screen, capsule.Position() + offset);
+ }
+}
+
+void BattleState::RenderHeroTags(SDL_Surface *screen) {
+ assert(screen);
+ int tagHeight(attackTypeMenu.Height());
+ int tagWidth(attackTypeMenu.Width() * 2 + attackTypeMenu.Width() / 2);
+
+ for (int i(0); i < battle.NumHeroes(); ++i) {
+ heroTags[i].Render(screen, tagWidth, tagHeight, heroTagPositions[i] + offset, battle.IsActiveHero(i));
+ }
+}
+
+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);
+
+ SDL_Rect rect;
+ rect.x = offset.X();
+ rect.y = offset.Y() + Height() - tagHeight;
+ rect.w = Width();
+ rect.h = tagHeight;
+ SDL_FillRect(screen, &rect, SDL_MapRGB(screen->format, 0, 0, 0));
+ rect.y += res->normalFont->CharHeight() / 8;
+ rect.h -= res->normalFont->CharHeight() / 4;
+ SDL_FillRect(screen, &rect, res->heroesBgColor.MapRGB(screen->format));
+
+ for (int i(0); i < battle.NumHeroes(); ++i) {
+ smallHeroTags[i].Render(screen, tagWidth, tagHeight, smallHeroTagPositions[i] + offset);