4 * Created on: Aug 7, 2012
8 #include "SelectMoveAction.h"
10 #include "SelectAttackType.h"
11 #include "SwapHeroes.h"
12 #include "../BattleState.h"
13 #include "../MoveMenu.h"
14 #include "../../app/Application.h"
15 #include "../../app/Input.h"
16 #include "../../geometry/operators.h"
18 using app::Application;
20 using geometry::Point;
21 using geometry::Vector;
25 void SelectMoveAction::EnterState(Application &c, SDL_Surface *screen) {
29 void SelectMoveAction::ExitState(Application &c, SDL_Surface *screen) {
33 void SelectMoveAction::ResumeState(Application &ctrl, SDL_Surface *screen) {
37 void SelectMoveAction::PauseState(Application &ctrl, SDL_Surface *screen) {
42 void SelectMoveAction::Resize(int width, int height) {
47 void SelectMoveAction::HandleInput(const Input &input) {
48 if (input.IsDown(Input::PAD_UP)) {
49 battle->GetMoveMenu().Select(MoveMenu::CHANGE);
50 } else if (input.IsDown(Input::PAD_DOWN)) {
51 battle->GetMoveMenu().Select(MoveMenu::RUN);
53 battle->GetMoveMenu().Select(MoveMenu::ATTACK);
56 if (input.JustPressed(Input::ACTION_A)) {
57 switch (battle->GetMoveMenu().Selected()) {
58 case MoveMenu::ATTACK:
59 ctrl->ChangeState(new SelectAttackType(battle));
62 case MoveMenu::CHANGE:
63 ctrl->PushState(new SwapHeroes(battle, this));
66 // TODO: switch to run state
72 void SelectMoveAction::UpdateWorld(float deltaT) {
76 void SelectMoveAction::Render(SDL_Surface *screen) {
77 Vector<int> offset(battle->CalculateScreenOffset(screen));
78 battle->RenderBackground(screen, offset);
79 battle->RenderMonsters(screen, offset);
80 battle->RenderHeroTags(screen, offset);
81 RenderMenu(screen, offset);
84 void SelectMoveAction::RenderMenu(SDL_Surface *screen, const Vector<int> &offset) {
86 (battle->BackgroundWidth() - battle->GetMoveMenu().Width()) / 2,
87 battle->BackgroundHeight() - battle->GetMoveMenu().Height() - battle->GetMoveMenu().Height() / 2);
88 battle->GetMoveMenu().Render(screen, position + offset);