4 * Created on: Aug 7, 2012
8 #include "SelectMoveAction.h"
11 #include "SelectAttackType.h"
12 #include "SwapHeroes.h"
13 #include "../BattleState.h"
14 #include "../MoveMenu.h"
15 #include "../../app/Application.h"
16 #include "../../app/Input.h"
17 #include "../../geometry/operators.h"
19 using app::Application;
21 using geometry::Point;
22 using geometry::Vector;
26 void SelectMoveAction::EnterState(Application &c, SDL_Surface *screen) {
30 void SelectMoveAction::ExitState(Application &c, SDL_Surface *screen) {
34 void SelectMoveAction::ResumeState(Application &ctrl, SDL_Surface *screen) {
38 void SelectMoveAction::PauseState(Application &ctrl, SDL_Surface *screen) {
43 void SelectMoveAction::Resize(int width, int height) {
48 void SelectMoveAction::HandleEvents(const Input &input) {
49 if (input.IsDown(Input::PAD_UP)) {
50 battle->GetMoveMenu().Select(MoveMenu::CHANGE);
51 } else if (input.IsDown(Input::PAD_DOWN)) {
52 battle->GetMoveMenu().Select(MoveMenu::RUN);
54 battle->GetMoveMenu().Select(MoveMenu::ATTACK);
57 if (input.JustPressed(Input::ACTION_A)) {
58 switch (battle->GetMoveMenu().Selected()) {
59 case MoveMenu::ATTACK:
60 ctrl->ChangeState(new SelectAttackType(battle));
63 case MoveMenu::CHANGE:
64 ctrl->PushState(new SwapHeroes(battle, this));
67 ctrl->ChangeState(new RunState(battle));
73 void SelectMoveAction::UpdateWorld(float deltaT) {
77 void SelectMoveAction::Render(SDL_Surface *screen) {
78 Vector<int> offset(battle->CalculateScreenOffset(screen));
79 battle->RenderBackground(screen, offset);
80 battle->RenderMonsters(screen, offset);
81 battle->RenderHeroTags(screen, offset);
82 RenderMenu(screen, offset);
85 void SelectMoveAction::RenderMenu(SDL_Surface *screen, const Vector<int> &offset) {
87 (battle->Width() - battle->GetMoveMenu().Width()) / 2,
88 battle->Height() - battle->GetMoveMenu().Height() - battle->GetMoveMenu().Height() / 2);
89 battle->GetMoveMenu().Render(screen, position + offset);