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) {
29 void RunState::ExitState(Application &c, SDL_Surface *screen) {
33 void RunState::ResumeState(Application &ctrl, SDL_Surface *screen) {
34 timer = GraphicsTimers().StartCountdown(2500);
37 void RunState::PauseState(Application &ctrl, SDL_Surface *screen) {
42 void RunState::Resize(int width, int height) {
47 void RunState::HandleEvents(const Input &input) {
48 if (timer.Finished()) {
50 ctrl->PopState(); // pop self
55 void RunState::UpdateWorld(float deltaT) {
59 void RunState::Render(SDL_Surface *screen) {
60 Vector<int> offset(battle->CalculateScreenOffset(screen));
61 battle->RenderBackground(screen, offset);
62 battle->RenderMonsters(screen, offset);
63 battle->RenderHeroes(screen, offset);
64 battle->RenderSmallHeroTags(screen, offset);
65 RenderTitleBar(screen, offset);
68 void RunState::RenderTitleBar(SDL_Surface *screen, const Vector<int> &offset) {
69 int height(battle->Res().titleFrame->BorderHeight() * 2 + battle->Res().titleFont->CharHeight());
70 battle->Res().titleFrame->Draw(screen, offset, battle->Width(), height);
72 Vector<int> textPosition(
73 (battle->Width() - (std::strlen(battle->Res().escapeText) * battle->Res().titleFont->CharWidth())) / 2,
74 battle->Res().titleFrame->BorderHeight());
75 battle->Res().titleFont->DrawString(battle->Res().escapeText, screen, textPosition + offset);