3 #include "../BattleState.h"
4 #include "../../app/Application.h"
5 #include "../../app/Input.h"
6 #include "../../math/Vector.h"
7 #include "../../graphics/Font.h"
8 #include "../../graphics/Frame.h"
12 using app::Application;
18 void RunState::OnEnterState(SDL_Surface *screen) {
19 OnResize(screen->w, screen->h);
22 void RunState::OnExitState(SDL_Surface *screen) {
26 void RunState::OnResumeState(SDL_Surface *screen) {
27 timer = GraphicsTimers().StartCountdown(2500);
30 void RunState::OnPauseState(SDL_Surface *screen) {
35 void RunState::OnResize(int width, int height) {
36 framePosition = battle->ScreenOffset();
37 frameSize = Vector<int> (
39 battle->Res().titleFrame->BorderHeight() * 2 + battle->Res().titleFont->CharHeight());
41 textPosition = Vector<int>(
42 (battle->Width() - std::strlen(battle->Res().escapeText) * battle->Res().titleFont->CharWidth()) / 2,
43 battle->Res().titleFrame->BorderHeight());
47 void RunState::HandleEvents(const Input &input) {
48 if (timer.Finished()) {
50 Ctrl().PopState(); // pop self
55 void RunState::UpdateWorld(Uint32 deltaT) {
59 void RunState::Render(SDL_Surface *screen) {
60 battle->RenderBackground(screen);
61 battle->RenderMonsters(screen);
62 battle->RenderHeroes(screen);
63 battle->RenderSmallHeroTags(screen);
64 RenderTitleBar(screen);
67 void RunState::RenderTitleBar(SDL_Surface *screen) {
68 const Resources &res = battle->Res();
69 res.titleFrame->Draw(screen, framePosition, frameSize.X(), frameSize.Y());
70 res.titleFont->DrawString(res.escapeText, screen, textPosition);