4 * Created on: Aug 10, 2012
10 #include "../BattleState.h"
11 #include "../../app/Application.h"
12 #include "../../app/Input.h"
13 #include "../../geometry/Vector.h"
14 #include "../../graphics/Font.h"
15 #include "../../graphics/Frame.h"
19 using app::Application;
21 using geometry::Vector;
25 void RunState::EnterState(Application &c, SDL_Surface *screen) {
27 // TODO: push battle animation if enemy is faster
30 void RunState::ExitState(Application &c, SDL_Surface *screen) {
34 void RunState::ResumeState(Application &ctrl, SDL_Surface *screen) {
35 timer = GraphicsTimers().StartCountdown(2500);
38 void RunState::PauseState(Application &ctrl, SDL_Surface *screen) {
43 void RunState::Resize(int width, int height) {
48 void RunState::HandleEvents(const Input &input) {
49 if (timer.Finished()) {
51 ctrl->PopState(); // pop self
56 void RunState::UpdateWorld(float deltaT) {
60 void RunState::Render(SDL_Surface *screen) {
61 Vector<int> offset(battle->CalculateScreenOffset(screen));
62 battle->RenderBackground(screen, offset);
63 battle->RenderMonsters(screen, offset);
64 battle->RenderHeroes(screen, offset);
65 battle->RenderSmallHeroTags(screen, offset);
66 RenderTitleBar(screen, offset);
69 void RunState::RenderTitleBar(SDL_Surface *screen, const Vector<int> &offset) {
70 int height(battle->Res().titleFrame->BorderHeight() * 2 + battle->Res().titleFont->CharHeight());
71 battle->Res().titleFrame->Draw(screen, offset, battle->Width(), height);
73 Vector<int> textPosition(
74 (battle->Width() - (std::strlen(battle->Res().escapeText) * battle->Res().titleFont->CharWidth())) / 2,
75 battle->Res().titleFrame->BorderHeight());
76 battle->Res().titleFont->DrawString(battle->Res().escapeText, screen, textPosition + offset);