#include "BattleState.h"
#include "PartyLayout.h"
+#include "../graphics/Sprite.h"
+
+#include <stdexcept>
using app::Application;
+using std::vector;
+
namespace battle {
+void BattleState::AddMonster(const Monster &m) {
+ if (monsters.size() >= monstersLayout->NumPositions()) {
+ throw std::overflow_error("too many monsters for layout");
+ }
+ monsters.push_back(m);
+}
+
+
void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) {
monstersLayout->CalculatePositions(background->w, background->h, monsterPositions);
}
void BattleState::Render(SDL_Surface *screen) {
// TODO: center background if screen bigger
SDL_BlitSurface(background, 0, screen, 0);
+ for (vector<Monster>::size_type i(0), end(monsters.size()); i < end; ++i) {
+ monsters[i].Sprite()->DrawCenterBottom(screen, monsterPositions[i]);
+ }
}
}