-include sources.mk
-include src/sdl/subdir.mk
-include src/graphics/subdir.mk
+-include src/battle/states/subdir.mk
-include src/battle/subdir.mk
-include src/app/subdir.mk
-include src/subdir.mk
src/sdl \
src \
src/graphics \
+src/battle/states \
src/battle \
src/app \
--- /dev/null
+################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables
+CPP_SRCS += \
+../src/battle/states/SelectAttackType.cpp \
+../src/battle/states/SelectMoveAction.cpp
+
+OBJS += \
+./src/battle/states/SelectAttackType.o \
+./src/battle/states/SelectMoveAction.o
+
+CPP_DEPS += \
+./src/battle/states/SelectAttackType.d \
+./src/battle/states/SelectMoveAction.d
+
+
+# Each subdirectory must supply rules for building sources it contributes
+src/battle/states/%.o: ../src/battle/states/%.cpp
+ @echo 'Building file: $<'
+ @echo 'Invoking: GCC C++ Compiler'
+ g++ -I/usr/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
+ @echo 'Finished building: $<'
+ @echo ' '
+
+
-include sources.mk
-include src/sdl/subdir.mk
-include src/graphics/subdir.mk
+-include src/battle/states/subdir.mk
-include src/battle/subdir.mk
-include src/app/subdir.mk
-include src/subdir.mk
src/sdl \
src \
src/graphics \
+src/battle/states \
src/battle \
src/app \
--- /dev/null
+################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables
+CPP_SRCS += \
+../src/battle/states/SelectAttackType.cpp \
+../src/battle/states/SelectMoveAction.cpp
+
+OBJS += \
+./src/battle/states/SelectAttackType.o \
+./src/battle/states/SelectMoveAction.o
+
+CPP_DEPS += \
+./src/battle/states/SelectAttackType.d \
+./src/battle/states/SelectMoveAction.d
+
+
+# Each subdirectory must supply rules for building sources it contributes
+src/battle/states/%.o: ../src/battle/states/%.cpp
+ @echo 'Building file: $<'
+ @echo 'Invoking: GCC C++ Compiler'
+ g++ -I/usr/include/SDL -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
+ @echo 'Finished building: $<'
+ @echo ' '
+
+
#include "BattleState.h"
#include "PartyLayout.h"
+#include "states/SelectMoveAction.h"
#include "../app/Application.h"
#include "../app/Input.h"
#include "../geometry/operators.h"
for (vector<Hero>::size_type i(0), end(heroes.size()); i < end; ++i) {
heroTags.push_back(HeroTag(&heroes[i], HeroTag::Alignment((i + 1) % 2)));
}
+ ctrl.PushState(new SelectMoveAction(this));
}
void BattleState::ExitState() {
void BattleState::HandleInput(const Input &input) {
- if (moveChoice == -1) {
- if (input.IsDown(Input::PAD_UP)) {
- moveMenu.Select(MoveMenu::CHANGE);
- } else if (input.IsDown(Input::PAD_DOWN)) {
- moveMenu.Select(MoveMenu::RUN);
- } else {
- moveMenu.Select(MoveMenu::ATTACK);
- }
-
- if (input.JustPressed(Input::ACTION_A)) {
- moveChoice = moveMenu.Selected();
- }
- } else {
- if (input.IsDown(Input::PAD_UP)) {
- attackTypeMenu.Select(AttackTypeMenu::MAGIC);
- } else if (input.IsDown(Input::PAD_RIGHT)) {
- attackTypeMenu.Select(AttackTypeMenu::DEFEND);
- } else if (input.IsDown(Input::PAD_DOWN)) {
- attackTypeMenu.Select(AttackTypeMenu::IKARI);
- } else if (input.IsDown(Input::PAD_LEFT)) {
- attackTypeMenu.Select(AttackTypeMenu::ITEM);
- } else {
- attackTypeMenu.Select(AttackTypeMenu::SWORD);
- }
-
- if (input.JustPressed(Input::ACTION_A)) {
- activeHero = (activeHero + 1) % 4;
- }
- }
+
}
void BattleState::UpdateWorld(float deltaT) {
}
void BattleState::Render(SDL_Surface *screen) {
- Vector<int> offset(
- (screen->w - background->w) / 2,
- (screen->h - background->h) / 2);
+ Vector<int> offset(CalculateScreenOffset(screen));
RenderBackground(screen, offset);
RenderMonsters(screen, offset);
// RenderHeroes(screen, offset);
RenderHeroTags(screen, offset);
- if (moveChoice == -1) {
- RenderMoveMenu(screen, offset);
- } else {
- RenderAttackTypeMenu(screen, offset);
- }
+ RenderAttackTypeMenu(screen, offset);
}
void BattleState::RenderBackground(SDL_Surface *screen, const Vector<int> &offset) {
}
void BattleState::RenderHeroTags(SDL_Surface *screen, const Vector<int> &offset) {
- int uiHeight(background->h / 2), uiOffset(uiHeight);
+ int uiHeight(BackgroundHeight() / 2), uiOffset(uiHeight);
int tagHeight((uiHeight - attackTypeMenu.IconHeight()) / 2);
- int tagWidth((background->w - attackTypeMenu.IconWidth()) / 2);
+ int tagWidth((BackgroundWidth() - attackTypeMenu.IconWidth()) / 2);
Point<int> tagPosition[4];
tagPosition[0] = Point<int>(0, uiOffset);
void BattleState::RenderAttackTypeMenu(SDL_Surface *screen, const Vector<int> &offset) {
Point<int> position(
- (background->w - attackTypeMenu.Width()) / 2,
- (background->h * 3 / 4) - (attackTypeMenu.Height() / 2));
+ (BackgroundWidth() - attackTypeMenu.Width()) / 2,
+ (BackgroundHeight() * 3 / 4) - (attackTypeMenu.Height() / 2));
attackTypeMenu.Render(screen, position + offset);
}
-void BattleState::RenderMoveMenu(SDL_Surface *screen, const Vector<int> &offset) {
- Point<int> position(
- (background->w - moveMenu.Width()) / 2,
- (background->h * 3 / 4) - (moveMenu.Height() / 2));
- moveMenu.Render(screen, position + offset);
-}
-
}
virtual void UpdateWorld(float deltaT);
virtual void Render(SDL_Surface *);
-private:
+public:
+ AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
+ MoveMenu &GetMoveMenu() { return moveMenu; }
+
+public:
+ geometry::Vector<int> CalculateScreenOffset(SDL_Surface *screen) const {
+ return geometry::Vector<int>(
+ (screen->w - background->w) / 2,
+ (screen->h - background->h) / 2);
+ }
+ int BackgroundWidth() const { return background->w; }
+ int BackgroundHeight() const { return background->h; }
+
void RenderBackground(SDL_Surface *screen, const geometry::Vector<int> &offset);
void RenderMonsters(SDL_Surface *screen, const geometry::Vector<int> &offset);
void RenderHeroes(SDL_Surface *screen, const geometry::Vector<int> &offset);
void RenderHeroTags(SDL_Surface *screen, const geometry::Vector<int> &offset);
void RenderAttackTypeMenu(SDL_Surface *screen, const geometry::Vector<int> &offset);
- void RenderMoveMenu(SDL_Surface *screen, const geometry::Vector<int> &offset);
private:
SDL_Surface *background;
--- /dev/null
+/*
+ * SelectAttackType.cpp
+ *
+ * Created on: Aug 7, 2012
+ * Author: holy
+ */
+
+#include "SelectAttackType.h"
+
+#include "../BattleState.h"
+#include "../../app/Input.h"
+#include "../../geometry/operators.h"
+
+using app::Input;
+using geometry::Point;
+using geometry::Vector;
+
+namespace battle {
+
+void SelectAttackType::EnterState(app::Application &c, SDL_Surface *screen) {
+ ctrl = &c;
+}
+
+void SelectAttackType::ExitState() {
+ ctrl = 0;
+}
+
+
+void SelectAttackType::Resize(int width, int height) {
+
+}
+
+
+void SelectAttackType::HandleInput(const Input &input) {
+ if (input.IsDown(Input::PAD_UP)) {
+ battle->GetAttackTypeMenu().Select(AttackTypeMenu::MAGIC);
+ } else if (input.IsDown(Input::PAD_RIGHT)) {
+ battle->GetAttackTypeMenu().Select(AttackTypeMenu::DEFEND);
+ } else if (input.IsDown(Input::PAD_DOWN)) {
+ battle->GetAttackTypeMenu().Select(AttackTypeMenu::IKARI);
+ } else if (input.IsDown(Input::PAD_LEFT)) {
+ battle->GetAttackTypeMenu().Select(AttackTypeMenu::ITEM);
+ } else {
+ battle->GetAttackTypeMenu().Select(AttackTypeMenu::SWORD);
+ }
+
+ if (input.JustPressed(Input::ACTION_A)) {
+ switch (battle->GetAttackTypeMenu().Selected()) {
+ case AttackTypeMenu::SWORD:
+ // TODO: switch to next character
+ break;
+ case AttackTypeMenu::MAGIC:
+ // TODO: switch to spell select
+ break;
+ case AttackTypeMenu::DEFEND:
+ // TODO: switch to next character
+ break;
+ case AttackTypeMenu::IKARI:
+ // TODO: switch to ikari attack select
+ break;
+ case AttackTypeMenu::ITEM:
+ // TODO: switch to item select
+ break;
+ }
+ }
+}
+
+void SelectAttackType::UpdateWorld(float deltaT) {
+
+}
+
+void SelectAttackType::Render(SDL_Surface *screen) {
+ Vector<int> offset(battle->CalculateScreenOffset(screen));
+ battle->RenderBackground(screen, offset);
+ battle->RenderMonsters(screen, offset);
+ battle->RenderHeroTags(screen, offset);
+ RenderMenu(screen, offset);
+}
+
+void SelectAttackType::RenderMenu(SDL_Surface *screen, const Vector<int> &offset) {
+ Point<int> position(
+ (battle->BackgroundWidth() - battle->GetAttackTypeMenu().Width()) / 2,
+ (battle->BackgroundHeight() * 3 / 4) - (battle->GetAttackTypeMenu().Height() / 2));
+ battle->GetAttackTypeMenu().Render(screen, position + offset);
+}
+
+}
--- /dev/null
+/*
+ * SelectAttackType.h
+ *
+ * Created on: Aug 7, 2012
+ * Author: holy
+ */
+
+#ifndef BATTLE_SELECTATTACKTYPE_H_
+#define BATTLE_SELECTATTACKTYPE_H_
+
+#include "../../app/State.h"
+#include "../../geometry/Vector.h"
+
+namespace battle {
+
+class AttackTypeMenu;
+class BattleState;
+
+class SelectAttackType
+: public app::State {
+
+public:
+ explicit SelectAttackType(BattleState *battle)
+ : ctrl(0), battle(battle) { }
+ ~SelectAttackType() { }
+
+public:
+ virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void ExitState();
+
+ virtual void Resize(int width, int height);
+
+ virtual void HandleInput(const app::Input &);
+ virtual void UpdateWorld(float deltaT);
+ virtual void Render(SDL_Surface *);
+
+private:
+ void RenderMenu(SDL_Surface *screen, const geometry::Vector<int> &offset);
+
+private:
+ app::Application *ctrl;
+ BattleState *battle;
+
+};
+
+}
+#endif /* BATTLE_SELECTATTACKTYPE_H_ */
--- /dev/null
+/*
+ * SelectMoveAction.cpp
+ *
+ * Created on: Aug 7, 2012
+ * Author: holy
+ */
+
+#include "SelectMoveAction.h"
+
+#include "SelectAttackType.h"
+#include "../BattleState.h"
+#include "../MoveMenu.h"
+#include "../../app/Application.h"
+#include "../../app/Input.h"
+#include "../../geometry/operators.h"
+
+using app::Input;
+using geometry::Point;
+using geometry::Vector;
+
+namespace battle {
+
+void SelectMoveAction::EnterState(app::Application &c, SDL_Surface *screen) {
+ ctrl = &c;
+}
+
+void SelectMoveAction::ExitState() {
+ ctrl = 0;
+}
+
+
+void SelectMoveAction::Resize(int width, int height) {
+
+}
+
+
+void SelectMoveAction::HandleInput(const app::Input &input) {
+ if (input.IsDown(Input::PAD_UP)) {
+ battle->GetMoveMenu().Select(MoveMenu::CHANGE);
+ } else if (input.IsDown(Input::PAD_DOWN)) {
+ battle->GetMoveMenu().Select(MoveMenu::RUN);
+ } else {
+ battle->GetMoveMenu().Select(MoveMenu::ATTACK);
+ }
+
+ if (input.JustPressed(Input::ACTION_A)) {
+ switch (battle->GetMoveMenu().Selected()) {
+ case MoveMenu::ATTACK:
+ ctrl->ChangeState(new SelectAttackType(battle));
+ break;
+ case MoveMenu::CHANGE:
+ // TODO: switch to change state
+ break;
+ case MoveMenu::RUN:
+ // TODO: switch to run state
+ break;
+ }
+ }
+}
+
+void SelectMoveAction::UpdateWorld(float deltaT) {
+
+}
+
+void SelectMoveAction::Render(SDL_Surface *screen) {
+ Vector<int> offset(battle->CalculateScreenOffset(screen));
+ battle->RenderBackground(screen, offset);
+ battle->RenderMonsters(screen, offset);
+ battle->RenderHeroTags(screen, offset);
+ RenderMenu(screen, offset);
+}
+
+void SelectMoveAction::RenderMenu(SDL_Surface *screen, const Vector<int> &offset) {
+ Point<int> position(
+ (battle->BackgroundWidth() - battle->GetMoveMenu().Width()) / 2,
+ (battle->BackgroundHeight() * 3 / 4) - (battle->GetMoveMenu().Height() / 2));
+ battle->GetMoveMenu().Render(screen, position + offset);
+}
+
+}
--- /dev/null
+/*
+ * SelectMoveAction.h
+ *
+ * Created on: Aug 7, 2012
+ * Author: holy
+ */
+
+#ifndef BATTLE_SELECTMOVEACTION_H_
+#define BATTLE_SELECTMOVEACTION_H_
+
+#include "../../app/State.h"
+#include "../../geometry/Vector.h"
+
+namespace battle {
+
+class BattleState;
+class MoveMenu;
+
+class SelectMoveAction
+: public app::State {
+
+public:
+ explicit SelectMoveAction(BattleState *battle)
+ : ctrl(0), battle(battle) { }
+ ~SelectMoveAction() { }
+
+public:
+ virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void ExitState();
+
+ virtual void Resize(int width, int height);
+
+ virtual void HandleInput(const app::Input &);
+ virtual void UpdateWorld(float deltaT);
+ virtual void Render(SDL_Surface *);
+
+private:
+ void RenderMenu(SDL_Surface *screen, const geometry::Vector<int> &offset);
+
+private:
+ app::Application *ctrl;
+ BattleState *battle;
+
+};
+
+}
+
+#endif /* BATTLE_SELECTMOVEACTION_H_ */