4 * Created on: Aug 7, 2012
8 #include "SelectMoveAction.h"
10 #include "SelectAttackType.h"
11 #include "../BattleState.h"
12 #include "../MoveMenu.h"
13 #include "../../app/Application.h"
14 #include "../../app/Input.h"
15 #include "../../geometry/operators.h"
18 using geometry::Point;
19 using geometry::Vector;
23 void SelectMoveAction::EnterState(app::Application &c, SDL_Surface *screen) {
27 void SelectMoveAction::ExitState() {
32 void SelectMoveAction::Resize(int width, int height) {
37 void SelectMoveAction::HandleInput(const app::Input &input) {
38 if (input.IsDown(Input::PAD_UP)) {
39 battle->GetMoveMenu().Select(MoveMenu::CHANGE);
40 } else if (input.IsDown(Input::PAD_DOWN)) {
41 battle->GetMoveMenu().Select(MoveMenu::RUN);
43 battle->GetMoveMenu().Select(MoveMenu::ATTACK);
46 if (input.JustPressed(Input::ACTION_A)) {
47 switch (battle->GetMoveMenu().Selected()) {
48 case MoveMenu::ATTACK:
49 ctrl->ChangeState(new SelectAttackType(battle));
52 case MoveMenu::CHANGE:
53 // TODO: switch to change state
56 // TODO: switch to run state
62 void SelectMoveAction::UpdateWorld(float deltaT) {
66 void SelectMoveAction::Render(SDL_Surface *screen) {
67 Vector<int> offset(battle->CalculateScreenOffset(screen));
68 battle->RenderBackground(screen, offset);
69 battle->RenderMonsters(screen, offset);
70 battle->RenderHeroTags(screen, offset);
71 RenderMenu(screen, offset);
74 void SelectMoveAction::RenderMenu(SDL_Surface *screen, const Vector<int> &offset) {
76 (battle->BackgroundWidth() - battle->GetMoveMenu().Width()) / 2,
77 (battle->BackgroundHeight() * 3 / 4) - (battle->GetMoveMenu().Height() / 2));
78 battle->GetMoveMenu().Render(screen, position + offset);