++curClass;
}
+void Capsule::NextClass() {
+ ++curClass;
+ if (curClass >= maxClass) {
+ curClass = 0;
+ }
+}
+
+void Capsule::PreviousClass() {
+ --curClass;
+ if (curClass < 0) {
+ curClass = maxClass - 1;
+ }
+}
+
Sprite *Capsule::BattleSprite() {
return GetClass().battleSprite;
const graphics::Sprite *AlignmentSprite() const { return alignmentSprite; }
void UpgradeClass();
+ void NextClass();
+ void PreviousClass();
Uint16 MaxHealth() const;
int partySize;
Capsule capsules[7];
+ int capsule;
int NumCapsules() const { return 7; }
- Capsule *capsule;
+ Capsule &GetCapsule() { return capsules[capsule]; }
+ const Capsule &GetCapsule() const { return capsules[capsule]; }
Inventory inventory;
gameState.capsules[1] = *caster.GetCapsule("flash");
gameState.capsules[1].UpgradeClass();
- gameState.capsule = &gameState.capsules[1];
+ gameState.capsules[1].UpgradeClass();
+ gameState.capsules[1].UpgradeClass();
+ gameState.capsules[1].UpgradeClass();
+ gameState.capsule = 1;
GameConfig gameConfig;
gameConfig.state = &gameState;
}
}
if (game->state->capsule) {
- battleState->SetCapsule(game->state->capsule);
+ battleState->SetCapsule(&game->state->GetCapsule());
}
for (battle::Monster **monster((*e)->MonstersBegin()); monster != (*e)->MonstersEnd(); ++monster) {
battleState->AddMonster(**monster);
if (input.JustPressed(Input::ACTION_B)) {
Ctrl().PopState();
}
+
+ if (input.JustPressed(Input::PAD_UP)) {
+ NextClass();
+ }
+ if (input.JustPressed(Input::PAD_RIGHT)) {
+ NextCapsule();
+ }
+ if (input.JustPressed(Input::PAD_DOWN)) {
+ PreviousClass();
+ }
+ if (input.JustPressed(Input::PAD_LEFT)) {
+ PreviousCapsule();
+ }
}
+void CapsuleChangeMenu::NextCapsule() {
+ int &index = parent->Game().state->capsule;
+ ++index;
+ index %= parent->Game().state->NumCapsules();
+ // skip unexplored
+ while (parent->Game().state->GetCapsule().MaxClass() <= 0) {
+ ++index;
+ index %= parent->Game().state->NumCapsules();
+ }
+}
+
+void CapsuleChangeMenu::PreviousCapsule() {
+ int &index = parent->Game().state->capsule;
+ --index;
+ if (index < 0) index += parent->Game().state->NumCapsules();
+ // skip unexplored
+ while (GetCapsule().MaxClass() <= 0) {
+ --index;
+ if (index < 0) index += parent->Game().state->NumCapsules();
+ }
+}
+
+void CapsuleChangeMenu::NextClass() {
+ GetCapsule().NextClass();
+}
+
+void CapsuleChangeMenu::PreviousClass() {
+ GetCapsule().PreviousClass();
+}
+
+
void CapsuleChangeMenu::UpdateWorld(float deltaT) {
}
parent->Res().capsuleSelectLadder->Draw(
screen, cursor,
j < parent->Game().state->capsules[i].MaxClass(), j);
- if (&parent->Game().state->capsules[i] == parent->Game().state->capsule
+ if (i == parent->Game().state->capsule
&& parent->Game().state->capsules[i].CurrentClass() == j) {
parent->Res().capsuleSelectCursor->Draw(screen, cursor);
}
return parent->Height();
}
+Capsule &CapsuleChangeMenu::GetCapsule() {
+ return parent->GetCapsule();
+}
+
const Capsule &CapsuleChangeMenu::GetCapsule() const {
return parent->GetCapsule();
}
int Width() const;
int Height() const;
+ void NextCapsule();
+ void PreviousCapsule();
+ void NextClass();
+ void PreviousClass();
+
private:
virtual void OnEnterState(SDL_Surface *screen);
virtual void OnExitState(SDL_Surface *screen);
virtual void OnResize(int width, int height);
+ common::Capsule &GetCapsule();
const common::Capsule &GetCapsule() const;
private:
void CapsuleMenu::RenderWheel(SDL_Surface *screen, const Vector<int> &offset) const {
Res().capsuleAlignmentWheel->DrawCenter(screen, offset);
- Res().capsuleAlignmentCursor->DrawCenter(screen, offset + Game().state->capsule->AlignmentOffset());
+ Res().capsuleAlignmentCursor->DrawCenter(screen, offset + Game().state->GetCapsule().AlignmentOffset());
}
void CapsuleMenu::RenderStats(SDL_Surface *screen, const Vector<int> &offset) const {
}
Capsule &CapsuleMenu::GetCapsule() {
- return *Game().state->capsule;
+ return Game().state->GetCapsule();
}
const Capsule &CapsuleMenu::GetCapsule() const {
- return *Game().state->capsule;
+ return Game().state->GetCapsule();
}
}
-Sprite flashSprite {
+Sprite flashSprite1 {
image: :"flash.png",
size: <96, 96>
}
+Sprite flashSprite2 {
+ image: :"flash.png",
+ size: <96, 96>,
+ offset: <96, 0>
+}
+Sprite flashSprite3 {
+ image: :"flash.png",
+ size: <96, 96>,
+ offset: <192, 0>
+}
+Sprite flashSprite4 {
+ image: :"flash.png",
+ size: <96, 96>,
+ offset: <288, 0>
+}
+Sprite flashSpriteM {
+ image: :"flash.png",
+ size: <96, 96>,
+ offset: <384, 0>
+}
export Capsule flash {
name: "Flash",
{
name: "1 TODO",
tribe: "Shaggy",
- battleSprite: flashSprite,
+ battleSprite: flashSprite1,
meleeAnimation: SimpleAnimation {
sprite: Sprite {
image: :"melee-maxim.png",
framecount: 4
},
attackAnimation: ComplexAnimation {
- sprite: flashSprite,
+ sprite: flashSprite1,
frametime: fourFramesTime,
repeat: false,
frames:
{
name: "2 TODO",
tribe: "Sprite",
- battleSprite: flashSprite,
+ battleSprite: flashSprite2,
meleeAnimation: SimpleAnimation {
sprite: Sprite {
image: :"melee-maxim.png",
framecount: 4
},
attackAnimation: ComplexAnimation {
- sprite: flashSprite,
+ sprite: flashSprite2,
frametime: fourFramesTime,
repeat: false,
frames:
{
name: "3 TODO",
tribe: "Cupid",
- battleSprite: flashSprite,
+ battleSprite: flashSprite3,
meleeAnimation: SimpleAnimation {
sprite: Sprite {
image: :"melee-maxim.png",
framecount: 4
},
attackAnimation: ComplexAnimation {
- sprite: flashSprite,
+ sprite: flashSprite3,
frametime: fourFramesTime,
repeat: false,
frames:
{
name: "4",
tribe: "Twinkle",
- battleSprite: flashSprite,
+ battleSprite: flashSprite4,
meleeAnimation: SimpleAnimation {
sprite: Sprite {
image: :"melee-maxim.png",
framecount: 4
},
attackAnimation: ComplexAnimation {
- sprite: flashSprite,
+ sprite: flashSprite4,
frametime: fourFramesTime,
repeat: false,
frames:
{
name: "M TODO",
tribe: "Twinkle",
- battleSprite: flashSprite,
+ battleSprite: flashSpriteM,
meleeAnimation: SimpleAnimation {
sprite: Sprite {
image: :"melee-maxim.png",
framecount: 4
},
attackAnimation: ComplexAnimation {
- sprite: flashSprite,
+ sprite: flashSpriteM,
frametime: fourFramesTime,
repeat: false,
frames: