# Add inputs and outputs from these tool invocations to the build variables
CPP_SRCS += \
+../src/battle/states/RunState.cpp \
../src/battle/states/SelectAttackType.cpp \
../src/battle/states/SelectIkari.cpp \
../src/battle/states/SelectItem.cpp \
../src/battle/states/SwapHeroes.cpp
OBJS += \
+./src/battle/states/RunState.o \
./src/battle/states/SelectAttackType.o \
./src/battle/states/SelectIkari.o \
./src/battle/states/SelectItem.o \
./src/battle/states/SwapHeroes.o
CPP_DEPS += \
+./src/battle/states/RunState.d \
./src/battle/states/SelectAttackType.d \
./src/battle/states/SelectIkari.d \
./src/battle/states/SelectItem.d \
# Add inputs and outputs from these tool invocations to the build variables
CPP_SRCS += \
+../src/battle/states/RunState.cpp \
../src/battle/states/SelectAttackType.cpp \
../src/battle/states/SelectIkari.cpp \
../src/battle/states/SelectItem.cpp \
../src/battle/states/SwapHeroes.cpp
OBJS += \
+./src/battle/states/RunState.o \
./src/battle/states/SelectAttackType.o \
./src/battle/states/SelectIkari.o \
./src/battle/states/SelectItem.o \
./src/battle/states/SwapHeroes.o
CPP_DEPS += \
+./src/battle/states/RunState.d \
./src/battle/states/SelectAttackType.d \
./src/battle/states/SelectIkari.d \
./src/battle/states/SelectItem.d \
break;
}
}
- CurrentState()->HandleInput(input);
+ CurrentState()->HandleEvents(input);
}
void Application::UpdateWorld(Uint32 deltaT) {
/// adapt the state's graphics to given dimensions
virtual void Resize(int width, int height) = 0;
- virtual void HandleInput(const Input &) = 0;
+ virtual void HandleEvents(const Input &) = 0;
virtual void UpdateWorld(float deltaT) = 0;
virtual void Render(SDL_Surface *) = 0;
}
-void BattleState::HandleInput(const Input &input) {
+void BattleState::HandleEvents(const Input &input) {
}
virtual void Resize(int width, int height);
- virtual void HandleInput(const app::Input &);
+ virtual void HandleEvents(const app::Input &);
virtual void UpdateWorld(float deltaT);
virtual void Render(SDL_Surface *);
--- /dev/null
+/*
+ * RunState.cpp
+ *
+ * Created on: Aug 10, 2012
+ * Author: holy
+ */
+
+#include "RunState.h"
+
+#include "../BattleState.h"
+#include "../../app/Application.h"
+#include "../../app/Input.h"
+#include "../../geometry/operators.h"
+#include "../../geometry/Point.h"
+
+using app::Application;
+using app::Input;
+using geometry::Point;
+using geometry::Vector;
+
+namespace battle {
+
+void RunState::EnterState(Application &c, SDL_Surface *screen) {
+ ctrl = &c;
+ // TODO: push battle animation if enemy is faster
+}
+
+void RunState::ExitState(Application &c, SDL_Surface *screen) {
+ ctrl = 0;
+}
+
+void RunState::ResumeState(Application &ctrl, SDL_Surface *screen) {
+ timer = GraphicsTimers().StartCountdown(2500);
+}
+
+void RunState::PauseState(Application &ctrl, SDL_Surface *screen) {
+
+}
+
+
+void RunState::Resize(int width, int height) {
+
+}
+
+
+void RunState::HandleEvents(const Input &input) {
+ if (timer.Finished()) {
+ ctrl->PopState(); // pop self
+ ctrl->PopState(); // pop battle
+ }
+}
+
+
+void RunState::UpdateWorld(float deltaT) {
+
+}
+
+void RunState::Render(SDL_Surface *screen) {
+ Vector<int> offset(battle->CalculateScreenOffset(screen));
+ battle->RenderBackground(screen, offset);
+ battle->RenderMonsters(screen, offset);
+ battle->RenderHeroes(screen, offset);
+ // render small tags
+}
+
+}
--- /dev/null
+/*
+ * RunState.h
+ *
+ * Created on: Aug 10, 2012
+ * Author: holy
+ */
+
+#ifndef BATTLE_RUNSTATE_H_
+#define BATTLE_RUNSTATE_H_
+
+#include "../../app/State.h"
+
+#include "../../geometry/Vector.h"
+
+namespace battle {
+
+class BattleState;
+
+class RunState
+: public app::State {
+
+public:
+ explicit RunState(BattleState *battle)
+ : ctrl(0), battle(battle){ }
+
+public:
+ virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
+
+ virtual void Resize(int width, int height);
+
+ virtual void HandleEvents(const app::Input &);
+ virtual void UpdateWorld(float deltaT);
+ virtual void Render(SDL_Surface *);
+
+private:
+ app::Application *ctrl;
+ BattleState *battle;
+ app::Timer<Uint32> timer;
+
+};
+
+}
+
+#endif /* BATTLE_RUNSTATE_H_ */
}
-void SelectAttackType::HandleInput(const Input &input) {
+void SelectAttackType::HandleEvents(const Input &input) {
if (input.IsDown(Input::PAD_UP)) {
battle->GetAttackTypeMenu().Select(AttackChoice::MAGIC);
} else if (input.IsDown(Input::PAD_RIGHT)) {
virtual void Resize(int width, int height);
- virtual void HandleInput(const app::Input &);
+ virtual void HandleEvents(const app::Input &);
virtual void UpdateWorld(float deltaT);
virtual void Render(SDL_Surface *);
}
-void SelectIkari::HandleInput(const Input &input) {
+void SelectIkari::HandleEvents(const Input &input) {
if (input.JustPressed(Input::ACTION_A)) {
if (battle->GetIkariMenu().SelectedIsEnabled() && battle->GetIkariMenu().Selected()->HasIkari()) {
const Ikari *ikari(battle->GetIkariMenu().Selected()->GetIkari());
virtual void Resize(int width, int height);
- virtual void HandleInput(const app::Input &);
+ virtual void HandleEvents(const app::Input &);
virtual void UpdateWorld(float deltaT);
virtual void Render(SDL_Surface *);
}
-void SelectItem::HandleInput(const Input &input) {
+void SelectItem::HandleEvents(const Input &input) {
if (input.JustPressed(Input::ACTION_A)) {
if (battle->GetItemMenu().SelectedIsEnabled()) {
const Item *item(battle->GetItemMenu().Selected());
virtual void Resize(int width, int height);
- virtual void HandleInput(const app::Input &);
+ virtual void HandleEvents(const app::Input &);
virtual void UpdateWorld(float deltaT);
virtual void Render(SDL_Surface *);
#include "SelectMoveAction.h"
+#include "RunState.h"
#include "SelectAttackType.h"
#include "SwapHeroes.h"
#include "../BattleState.h"
}
-void SelectMoveAction::HandleInput(const Input &input) {
+void SelectMoveAction::HandleEvents(const Input &input) {
if (input.IsDown(Input::PAD_UP)) {
battle->GetMoveMenu().Select(MoveMenu::CHANGE);
} else if (input.IsDown(Input::PAD_DOWN)) {
ctrl->PushState(new SwapHeroes(battle, this));
break;
case MoveMenu::RUN:
- // TODO: switch to run state
+ ctrl->ChangeState(new RunState(battle));
break;
}
}
virtual void Resize(int width, int height);
- virtual void HandleInput(const app::Input &);
+ virtual void HandleEvents(const app::Input &);
virtual void UpdateWorld(float deltaT);
virtual void Render(SDL_Surface *);
}
-void SelectSpell::HandleInput(const Input &input) {
+void SelectSpell::HandleEvents(const Input &input) {
if (input.JustPressed(Input::ACTION_A)) {
if (battle->GetSpellMenu().SelectedIsEnabled()) {
const Spell *spell(battle->GetSpellMenu().Selected());
virtual void Resize(int width, int height);
- virtual void HandleInput(const app::Input &);
+ virtual void HandleEvents(const app::Input &);
virtual void UpdateWorld(float deltaT);
virtual void Render(SDL_Surface *);
}
-void SelectTarget::HandleInput(const Input &input) {
+void SelectTarget::HandleEvents(const Input &input) {
if (input.JustPressed(Input::ACTION_A)) {
if (selection->CurrentIsSelected()) {
ctrl->PopState(); // return control to parent
virtual void Resize(int width, int height);
- virtual void HandleInput(const app::Input &);
+ virtual void HandleEvents(const app::Input &);
virtual void UpdateWorld(float deltaT);
virtual void Render(SDL_Surface *);
}
-void SwapHeroes::HandleInput(const Input &input) {
+void SwapHeroes::HandleEvents(const Input &input) {
if (input.JustPressed(Input::ACTION_A)) {
if (selected != -1 && cursor != selected) {
battle->SwapHeroes(cursor, selected);
virtual void Resize(int width, int height);
- virtual void HandleInput(const app::Input &);
+ virtual void HandleEvents(const app::Input &);
virtual void UpdateWorld(float deltaT);
virtual void Render(SDL_Surface *);