]> git.localhorst.tv Git - l2e.git/blob - src/battle/BattleState.cpp
better positioning of monsters
[l2e.git] / src / battle / BattleState.cpp
1 /*
2  * BattleState.cpp
3  *
4  *  Created on: Aug 5, 2012
5  *      Author: holy
6  */
7
8 #include "BattleState.h"
9
10 #include "PartyLayout.h"
11 #include "../graphics/Sprite.h"
12
13 #include <stdexcept>
14
15 using app::Application;
16
17 using std::vector;
18
19 namespace battle {
20
21 void BattleState::AddMonster(const Monster &m) {
22         if (monsters.size() >= monstersLayout->NumPositions()) {
23                 throw std::overflow_error("too many monsters for layout");
24         }
25         monsters.push_back(m);
26 }
27
28
29 void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) {
30         monstersLayout->CalculatePositions(background->w, background->h, monsterPositions);
31 }
32
33 void BattleState::ExitState() {
34
35 }
36
37
38 void BattleState::HandleEvent(const SDL_Event &) {
39
40 }
41
42 void BattleState::UpdateWorld(float deltaT) {
43
44 }
45
46 void BattleState::Render(SDL_Surface *screen) {
47         // TODO: center background if screen bigger
48         SDL_BlitSurface(background, 0, screen, 0);
49         for (vector<Monster>::size_type i(0), end(monsters.size()); i < end; ++i) {
50                 monsters[i].Sprite()->DrawCenterBottom(screen, monsterPositions[i]);
51         }
52 }
53
54 }