CombatState currentCombatState = TURN_ORDER;
-
-
static double frameTimer = 0;
static const double frameTime = 1.0f / 60.0f;
-//bool playerTurn = true;
-
SDL_Texture* arrowSprite = nullptr;
SDL_Texture* indicatorSprite = nullptr;
SDL_Texture* indicatorRedSprite = nullptr;
S2DE::Vec2<float> moveCursorPos;
S2DE::Vec2<float> arenaCenter = { 23, 11 };
-//S2DE::Vec2<float>* currentMoveDest = &moveCursorPos;
-
static const int numActions = 4;
static const char* actions[numActions] = {"Move", "Attack", "End", "FLEE"};
int currentAction = 0;
void renderCombatants() {
- for (Character c : combatants) {
+ // this fucking sucks:
+ std::vector<Character> combatantsRender = combatants;
+ std::sort(combatantsRender.begin(), combatantsRender.end(),
+ [](const Character& a, const Character& b) {
+ return a.position.y < b.position.y;
+ });
+
+ for (Character c : combatantsRender) {
if (c.alive) {
S2DE::Vec2<float> pos = c.position;
SDL_Texture* texture = c.texture;
S2DE::renderTexture(&renderer, &texture, &charSRect, &charDRect);
- float hpLvl = (float)c.currentHP / (float)c.maxHP;
- renderMeter(charDRect.x + 6, charDRect.y - 6, charDRect.w - 12, 6, hpLvl, hpColour, 1);
+ if (!c.allied) {
+ float hpLvl = (float)c.currentHP / (float)c.maxHP;
+ renderMeter(charDRect.x + 6, charDRect.y - 6, charDRect.w - 12, 6, hpLvl, hpColour, 1);
+ }
}
}
bool checkCharacterCollision(S2DE::Vec2<float> position) {
for (auto c : combatants) {
- if (c.name != activeCombatant->name) { // this sucks
+ if (c.name != activeCombatant->name && c.alive) {
float charMinX = c.position.x;
float charMaxX = c.position.x + 1.0;
float charMinY = c.position.y;