: name("")
, alignment("")
+, alignmentSprite(0)
+
, maxHealth(0)
, level(1)
, classes(0)
, numClasses(0)
-, curClass(0)
+, curClass(-1)
, maxClass(0) {
}
}
}
+void Capsule::UpgradeClass() {
+ ++maxClass;
+ ++curClass;
+}
+
Sprite *Capsule::BattleSprite() {
return GetClass().battleSprite;
td.AddField("name", FieldDescription(((char *)&c.name) - ((char *)&c), Interpreter::STRING_ID).SetReferenced());
td.AddField("alignment", FieldDescription(((char *)&c.alignment) - ((char *)&c), Interpreter::STRING_ID).SetReferenced());
+ td.AddField("alignmentCursor", FieldDescription(((char *)&c.alignmentCursor) - ((char *)&c), Interpreter::VECTOR_ID));
+ td.AddField("alignmentSprite", FieldDescription(((char *)&c.alignmentSprite) - ((char *)&c), Sprite::TYPE_ID).SetReferenced());
+
td.AddField("maxHealth", FieldDescription(((char *)&c.maxHealth) - ((char *)&c), Interpreter::NUMBER_ID));
td.AddField("stats", FieldDescription(((char *)&c.stats) - ((char *)&c), Stats::TYPE_ID));
}
#include "../common/Stats.h"
+#include "../geometry/Vector.h"
#include <SDL.h>
const Spell *Attack2() const;
const Spell *Attack3() const;
+ int NumClasses() const { return numClasses; }
+ int MaxClass() const { return maxClass; }
+ int CurrentClass() const { return curClass; }
+
+ const geometry::Vector<int> &AlignmentOffset() const { return alignmentCursor; }
+ const graphics::Sprite *AlignmentSprite() const { return alignmentSprite; }
+
+ void UpgradeClass();
+
Uint16 MaxHealth() const;
Stats GetStats() const;
const char *name;
const char *alignment;
+ geometry::Vector<int> alignmentCursor;
+ const graphics::Sprite *alignmentSprite;
+
int maxHealth;
Stats stats;
GameState();
Hero heroes[7];
+ int NumHeroes() const { return 7; }
Hero *party[4];
int partySize;
Capsule capsules[7];
+ int NumCapsules() const { return 7; }
Capsule *capsule;
Inventory inventory;
gameState.party[3] = &gameState.heroes[3];
gameState.partySize = 4;
- gameState.capsules[0] = *caster.GetCapsule("flash");
- gameState.capsule = gameState.capsules;
+ gameState.capsules[1] = *caster.GetCapsule("flash");
+ gameState.capsules[1].UpgradeClass();
+ gameState.capsule = &gameState.capsules[1];
GameConfig gameConfig;
gameConfig.state = &gameState;
#include "../common/GameState.h"
#include "../graphics/Font.h"
#include "../graphics/Frame.h"
+#include "../graphics/Texture.h"
using app::Input;
using common::Capsule;
12 * font.CharWidth(),
2 * font.CharHeight() - font.CharHeight() / 8);
// TODO: wheel offset: top left, center, or center bottom?
- const Vector<int> wheelOffset;
+ const Vector<int> wheelOffset(
+ 6 * font.CharWidth(),
+ 19 * font.CharHeight() - font.CharHeight() / 8);
+ const Vector<int> classesOffset(
+ 12 * font.CharWidth(),
+ 13 * font.CharHeight() - font.CharHeight() / 8);
const Vector<int> menuOffset(
- font.CharWidth(),
- 24 * font.CharHeight() - font.CharHeight() / 8);
+ font.CharWidth(),
+ 24 * font.CharHeight() - font.CharHeight() / 8);
parent->RenderBackground(screen);
parent->RenderCapsule(screen, offset + capsuleOffset);
parent->RenderInfo(screen, offset + infoOffset);
parent->RenderWheel(screen, offset + wheelOffset);
+ RenderClasses(screen, offset + classesOffset);
parent->RenderMenu(screen, offset + menuOffset);
}
+void CapsuleChangeMenu::RenderClasses(SDL_Surface *screen, const Vector<int> &offset) const {
+ Vector<int> cursor(offset);
+
+ int numClasses = 0;
+ for (int i = 0; i < parent->Game().state->NumCapsules(); ++i) {
+ if (numClasses < parent->Game().state->capsules[i].NumClasses()) {
+ numClasses = parent->Game().state->capsules[i].NumClasses();
+ }
+ }
+
+ parent->Res().capsuleSelectTopLeft->Draw(screen, cursor);
+ cursor.Y() += parent->Res().capsuleSelectTopLeft->Height();
+ Vector<int> target(
+ cursor.X() + parent->Res().capsuleSelectTopLeft->Width(),
+ cursor.Y() + numClasses * parent->Res().capsuleSelectLadder->Height());
+ parent->Res().capsuleSelectLeftRepeat->Render(screen, cursor, target);
+ cursor.Y() = target.Y();
+ parent->Res().capsuleSelectBottomLeft->Draw(screen, cursor);
+ cursor.X() += parent->Res().capsuleSelectTopLeft->Width();
+
+ for (int i = 0; i < parent->Game().state->NumCapsules(); ++i) {
+ cursor.Y() = offset.Y();
+ parent->Res().capsuleSelectTopRepeat->Draw(screen, cursor);
+ cursor.Y() += parent->Res().capsuleSelectTopRepeat->Height();
+ for (int j = numClasses - 1; j >= 0; --j) {
+ parent->Res().capsuleSelectLadder->Draw(
+ screen, cursor,
+ j < parent->Game().state->capsules[i].MaxClass(), j);
+ if (&parent->Game().state->capsules[i] == parent->Game().state->capsule
+ && parent->Game().state->capsules[i].CurrentClass() == j) {
+ parent->Res().capsuleSelectCursor->Draw(screen, cursor);
+ }
+ cursor.Y() += parent->Res().capsuleSelectLadder->Height();
+ }
+ parent->Res().capsuleSelectBottomRepeat->Draw(screen, cursor);
+ if (parent->Game().state->capsules[i].AlignmentSprite()) {
+ parent->Game().state->capsules[i].AlignmentSprite()->Draw(screen, cursor);
+ }
+ cursor.X() += parent->Res().capsuleSelectLadder->Width();
+ }
+
+ cursor.Y() = offset.Y();
+ parent->Res().capsuleSelectTopRight->Draw(screen, cursor);
+ cursor.Y() += parent->Res().capsuleSelectTopRight->Height();
+ target = Vector<int>(
+ cursor.X() + parent->Res().capsuleSelectTopRight->Width(),
+ cursor.Y() + numClasses * parent->Res().capsuleSelectLadder->Height());
+ parent->Res().capsuleSelectRightRepeat->Render(screen, cursor, target);
+ cursor.Y() = target.Y();
+ parent->Res().capsuleSelectBottomRight->Draw(screen, cursor);
+}
+
int CapsuleChangeMenu::Width() const {
return parent->Width();
virtual void UpdateWorld(float deltaT);
virtual void Render(SDL_Surface *);
+ void RenderClasses(SDL_Surface *, const geometry::Vector<int> &) const;
+
public:
int Width() const;
int Height() const;
12 * font.CharWidth(),
2 * font.CharHeight() - font.CharHeight() / 8);
// TODO: wheel offset: top left, center, or center bottom?
- const Vector<int> wheelOffset;
+ const Vector<int> wheelOffset(
+ 6 * font.CharWidth(),
+ 19 * font.CharHeight() - font.CharHeight() / 8);
const Vector<int> statsOffset(
12 * font.CharWidth(),
15 * font.CharHeight() - font.CharHeight() / 8);
}
void CapsuleMenu::RenderWheel(SDL_Surface *screen, const Vector<int> &offset) const {
- // later
+ Res().capsuleAlignmentWheel->DrawCenter(screen, offset);
+ Res().capsuleAlignmentCursor->DrawCenter(screen, offset + Game().state->capsule->AlignmentOffset());
}
void CapsuleMenu::RenderStats(SDL_Surface *screen, const Vector<int> &offset) const {
, capsuleNameCharSelectTemplate(0)
+, capsuleSelectTopLeft(0)
+, capsuleSelectTopRight(0)
+, capsuleSelectTopRepeat(0)
+, capsuleSelectBottomLeft(0)
+, capsuleSelectBottomRight(0)
+, capsuleSelectBottomRepeat(0)
+, capsuleSelectLeftRepeat(0)
+, capsuleSelectRightRepeat(0)
+, capsuleSelectLadder(0)
+, capsuleSelectCursor(0)
+
+, capsuleAlignmentWheel(0)
+, capsuleAlignmentCursor(0)
+
{ }
td.AddField("capsuleNotHungryText", FieldDescription(((char *)&r.capsuleNotHungryText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced());
td.AddField("capsuleNameSelect", FieldDescription(((char *)&r.capsuleNameCharSelectTemplate) - ((char *)&r), CharSelect::TYPE_ID).SetReferenced().SetDescription("properties of the letter array for changing the capsule name"));
+
+ td.AddField("capsuleSelectTopLeft", FieldDescription(((char *)&r.capsuleSelectTopLeft) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+ td.AddField("capsuleSelectTopRight", FieldDescription(((char *)&r.capsuleSelectTopRight) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+ td.AddField("capsuleSelectTopRepeat", FieldDescription(((char *)&r.capsuleSelectTopRepeat) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+ td.AddField("capsuleSelectBottomLeft", FieldDescription(((char *)&r.capsuleSelectBottomLeft) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+ td.AddField("capsuleSelectBottomRight", FieldDescription(((char *)&r.capsuleSelectBottomRight) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+ td.AddField("capsuleSelectBottomRepeat", FieldDescription(((char *)&r.capsuleSelectBottomRepeat) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+ td.AddField("capsuleSelectLeftRepeat", FieldDescription(((char *)&r.capsuleSelectLeftRepeat) - ((char *)&r), Texture::TYPE_ID).SetReferenced());
+ td.AddField("capsuleSelectRightRepeat", FieldDescription(((char *)&r.capsuleSelectRightRepeat) - ((char *)&r), Texture::TYPE_ID).SetReferenced());
+ td.AddField("capsuleSelectLadder", FieldDescription(((char *)&r.capsuleSelectLadder) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+ td.AddField("capsuleSelectCursor", FieldDescription(((char *)&r.capsuleSelectCursor) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+
+ td.AddField("capsuleAlignmentWheel", FieldDescription(((char *)&r.capsuleAlignmentWheel) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
+ td.AddField("capsuleAlignmentCursor", FieldDescription(((char *)&r.capsuleAlignmentCursor) - ((char *)&r), Sprite::TYPE_ID).SetReferenced());
}
void Resources::Construct(void *data) {
graphics::CharSelect *capsuleNameCharSelectTemplate;
+ graphics::Sprite *capsuleSelectTopLeft;
+ graphics::Sprite *capsuleSelectTopRight;
+ graphics::Sprite *capsuleSelectTopRepeat;
+ graphics::Sprite *capsuleSelectBottomLeft;
+ graphics::Sprite *capsuleSelectBottomRight;
+ graphics::Sprite *capsuleSelectBottomRepeat;
+ graphics::Texture *capsuleSelectLeftRepeat;
+ graphics::Texture *capsuleSelectRightRepeat;
+ graphics::Sprite *capsuleSelectLadder;
+ graphics::Sprite *capsuleSelectCursor;
+
+ graphics::Sprite *capsuleAlignmentWheel;
+ graphics::Sprite *capsuleAlignmentCursor;
+
Resources();
static void CreateTypeDescription();
export Capsule flash {
name: "Flash",
alignment: "LIGHT",
+ alignmentCursor: <-32, 0>,
+ alignmentSprite: Sprite {
+ image: :"capsule-sprites.png",
+ size: <32, 32>,
+ offset: <0, 96>
+ },
maxHealth: 5,
stats: Stats {
atp: 12,
mgr: 11
},
classes: [ CapsuleClass
+ {
+ name: "1 TODO",
+ tribe: "Shaggy",
+ battleSprite: flashSprite,
+ meleeAnimation: SimpleAnimation {
+ sprite: Sprite {
+ image: :"melee-maxim.png",
+ size: <96,96>
+ },
+ frametime: 66, // two "frames"
+ framecount: 4
+ },
+ attackAnimation: ComplexAnimation {
+ sprite: flashSprite,
+ frametime: fourFramesTime,
+ repeat: false,
+ frames:
+ [ ComplexAnimationFrame
+ { column: 0, row: 1, disposition: < 0, -16> },
+ { column: 0, row: 0, disposition: < 0, -16> },
+ { column: 0, row: 1, disposition: < 0, -16> },
+ { column: 0, row: 0, disposition: < 0, -16> }
+ ]
+ }
+ },
+ {
+ name: "2 TODO",
+ tribe: "Sprite",
+ battleSprite: flashSprite,
+ meleeAnimation: SimpleAnimation {
+ sprite: Sprite {
+ image: :"melee-maxim.png",
+ size: <96,96>
+ },
+ frametime: 66, // two "frames"
+ framecount: 4
+ },
+ attackAnimation: ComplexAnimation {
+ sprite: flashSprite,
+ frametime: fourFramesTime,
+ repeat: false,
+ frames:
+ [ ComplexAnimationFrame
+ { column: 0, row: 1, disposition: < 0, -16> },
+ { column: 0, row: 0, disposition: < 0, -16> },
+ { column: 0, row: 1, disposition: < 0, -16> },
+ { column: 0, row: 0, disposition: < 0, -16> }
+ ]
+ },
+ healthBoost: 208,
+ statBoost: Stats {
+ atp: 38,
+ dfp: 71,
+ str: 24,
+ agl: 78,
+ int: 195,
+ gut: 12, // TODO: this is probably higher, but clipped at 199
+ mgr: 135
+ }
+ },
+ {
+ name: "3 TODO",
+ tribe: "Cupid",
+ battleSprite: flashSprite,
+ meleeAnimation: SimpleAnimation {
+ sprite: Sprite {
+ image: :"melee-maxim.png",
+ size: <96,96>
+ },
+ frametime: 66, // two "frames"
+ framecount: 4
+ },
+ attackAnimation: ComplexAnimation {
+ sprite: flashSprite,
+ frametime: fourFramesTime,
+ repeat: false,
+ frames:
+ [ ComplexAnimationFrame
+ { column: 0, row: 1, disposition: < 0, -16> },
+ { column: 0, row: 0, disposition: < 0, -16> },
+ { column: 0, row: 1, disposition: < 0, -16> },
+ { column: 0, row: 0, disposition: < 0, -16> }
+ ]
+ },
+ healthBoost: 208,
+ statBoost: Stats {
+ atp: 38,
+ dfp: 71,
+ str: 24,
+ agl: 78,
+ int: 195,
+ gut: 12, // TODO: this is probably higher, but clipped at 199
+ mgr: 135
+ }
+ },
{
name: "4",
tribe: "Twinkle",
gut: 12, // TODO: this is probably higher, but clipped at 199
mgr: 135
}
+ },
+ {
+ name: "M TODO",
+ tribe: "Twinkle",
+ battleSprite: flashSprite,
+ meleeAnimation: SimpleAnimation {
+ sprite: Sprite {
+ image: :"melee-maxim.png",
+ size: <96,96>
+ },
+ frametime: 66, // two "frames"
+ framecount: 4
+ },
+ attackAnimation: ComplexAnimation {
+ sprite: flashSprite,
+ frametime: fourFramesTime,
+ repeat: false,
+ frames:
+ [ ComplexAnimationFrame
+ { column: 0, row: 1, disposition: < 0, -16> },
+ { column: 0, row: 0, disposition: < 0, -16> },
+ { column: 0, row: 1, disposition: < 0, -16> },
+ { column: 0, row: 0, disposition: < 0, -16> }
+ ]
+ },
+ healthBoost: 208,
+ statBoost: Stats {
+ atp: 38,
+ dfp: 71,
+ str: 24,
+ agl: 78,
+ int: 195,
+ gut: 12, // TODO: this is probably higher, but clipped at 199
+ mgr: 135
+ }
}
]
}
chars: "0123456789ABCDEabcdeFGHIJfghijKLMNOklmnoPQRSTpqrstUVWXYuvwxyZ!? z!? ",
width: 10,
groupX: 5
+ },
+ capsuleSelectTopLeft: Sprite {
+ image: :"capsule-sprites.png",
+ size: <32, 8>,
+ offset: <64, 0>
+ },
+ capsuleSelectTopRight: Sprite {
+ image: :"capsule-sprites.png",
+ size: <32, 8>,
+ offset: <128, 0>
+ },
+ capsuleSelectTopRepeat: Texture {
+ image: :"capsule-sprites.png",
+ size: <32, 8>,
+ offset: <96, 0>
+ },
+ capsuleSelectBottomLeft: Sprite {
+ image: :"capsule-sprites.png",
+ size: <32, 32>,
+ offset: <0, 32>
+ },
+ capsuleSelectBottomRight: Sprite {
+ image: :"capsule-sprites.png",
+ size: <32, 32>,
+ offset: <128, 64>
+ },
+ capsuleSelectBottomRepeat: Sprite {
+ image: :"capsule-sprites.png",
+ size: <32, 32>,
+ offset: <0, 64>
+ },
+ capsuleSelectLeftRepeat: Texture {
+ image: :"capsule-sprites.png",
+ size: <32, 32>
+ },
+ capsuleSelectRightRepeat: Texture {
+ image: :"capsule-sprites.png",
+ size: <32, 32>,
+ offset: <128, 32>
+ },
+ capsuleSelectLadder: Sprite {
+ image: :"capsule-sprites.png",
+ size: <32, 24>,
+ offset: <64, 8>
+ },
+ capsuleSelectCursor: Sprite {
+ image: :"capsule-sprites.png",
+ size: <32, 24>,
+ offset: <128, 8>
+ },
+ capsuleAlignmentWheel: Sprite {
+ image: :"capsule-sprites.png",
+ size: <128, 128>,
+ offset: <0, 128>
+ },
+ capsuleAlignmentCursor: Sprite {
+ image: :"capsule-sprites.png",
+ size: <32, 32>,
+ offset: <128, 128>
}
}